用VB6.0新建excel表格,并复制另一个已有的sheet1,复制到新建的表格中 代码如下:
PrivateSubCommand1_Click()DimbiaogeAsExcel.ApplicationSetbiaoge=CreateObject("excel.a...
Private Sub Command1_Click()
Dim biaoge As Excel.Application
Set biaoge = CreateObject("excel.application")
With biaoge
.Workbooks.Open "D:\D盘.xls"
.Workbooks.Open "C:\Documents and Settings\Administrator\桌面\桌面.xls"
.Workbooks("D盘.xls").Sheets("试验").Copy
.Workbooks ("桌面.xls") ‘就是这句错误
.Workbooks("桌面.xls").Save
.Workbooks("桌面.xls").Close
.Workbooks("D盘.xls").Close
.Quit
End With
End Sub
”提示错误,属性的使用无效“
谁能帮忙改改,谢谢 展开
Dim biaoge As Excel.Application
Set biaoge = CreateObject("excel.application")
With biaoge
.Workbooks.Open "D:\D盘.xls"
.Workbooks.Open "C:\Documents and Settings\Administrator\桌面\桌面.xls"
.Workbooks("D盘.xls").Sheets("试验").Copy
.Workbooks ("桌面.xls") ‘就是这句错误
.Workbooks("桌面.xls").Save
.Workbooks("桌面.xls").Close
.Workbooks("D盘.xls").Close
.Quit
End With
End Sub
”提示错误,属性的使用无效“
谁能帮忙改改,谢谢 展开
2个回答
展开全部
我的编程思路跟你的不一样,sheet类是不支持copy和paste操作的,你那样copy的话即使粘贴过去了也是个图片。
Private Sub Command1_Click()
Dim MyExcel As Excel.Application
Dim xlBook As Excel.Workbook
Dim MyExcel1 As Excel.Application
Dim xlBook1 As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlSheet1 As Excel.Worksheet
Set MyExcel = CreateObject("excel.application")
Set MyExcel1 = CreateObject("excel.application")
Set xlBook = MyExcel.Workbooks.Open("D:\D盘.xls")
Set xlBook1 = MyExcel.Workbooks.Open("C:\Documents and Settings\Administrator\桌面\桌面.xls")
Set xlSheet = xlBook.Sheets("试验")
Set xlSheet1 = xlBook1.Sheets("sheet1")
xlSheet.Range("A:IV").Copy Destination:=xlSheet1.Range("A1") ‘这就是复制到语句
xlBook.Save
xlBook1.Save
xlBook.Close
xlBook1.Close
Set xlBook = Nothing
Set xlSheet = Nothing
Set MyExcel = Nothing
Set xlBook1 = Nothing
Set xlSheet1 = Nothing
Set MyExcel1 = Nothing
End
End Sub
Private Sub Command1_Click()
Dim MyExcel As Excel.Application
Dim xlBook As Excel.Workbook
Dim MyExcel1 As Excel.Application
Dim xlBook1 As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlSheet1 As Excel.Worksheet
Set MyExcel = CreateObject("excel.application")
Set MyExcel1 = CreateObject("excel.application")
Set xlBook = MyExcel.Workbooks.Open("D:\D盘.xls")
Set xlBook1 = MyExcel.Workbooks.Open("C:\Documents and Settings\Administrator\桌面\桌面.xls")
Set xlSheet = xlBook.Sheets("试验")
Set xlSheet1 = xlBook1.Sheets("sheet1")
xlSheet.Range("A:IV").Copy Destination:=xlSheet1.Range("A1") ‘这就是复制到语句
xlBook.Save
xlBook1.Save
xlBook.Close
xlBook1.Close
Set xlBook = Nothing
Set xlSheet = Nothing
Set MyExcel = Nothing
Set xlBook1 = Nothing
Set xlSheet1 = Nothing
Set MyExcel1 = Nothing
End
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
工程引用:Microsoft Excel 12.0 Object Library 选择
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询