VB打开EXCEL要求对象
PrivateSubCommand1_Click()DimexlappAsObjectDimwbookAsObjectDimshtAsObjectSetexlapp=Cr...
Private Sub Command1_Click()
Dim exlapp As Object
Dim wbook As Object
Dim sht As Object
Set exlapp = CreateObject("excel.Application")
Set wbook = Application.Workbooks.Add
Set sht = wbook.sheets(1)
exlapp.Visible = True
End Sub
Set wbook = Application.Workbooks.Add这一句老是要报错
实时错误 “424” 要求对象,怎么回事呢? 展开
Dim exlapp As Object
Dim wbook As Object
Dim sht As Object
Set exlapp = CreateObject("excel.Application")
Set wbook = Application.Workbooks.Add
Set sht = wbook.sheets(1)
exlapp.Visible = True
End Sub
Set wbook = Application.Workbooks.Add这一句老是要报错
实时错误 “424” 要求对象,怎么回事呢? 展开
2个回答
展开全部
set wbook=exlapp.workbooks.add看看
建议改为
Dim exlApp As New Excel.Application '创建一个EXCEL程序实例
Dim wBook As Workbook '创建一工作簿实例
Dim sht As Worksheet '创建一个表单(Sheet)
set wbook=exlapp.workbooks.add '前面用了new关健字,所以不用建立excel.Application
Set sht = xlBook.Worksheets(1)
exlApp.Visible = True
dim sFileName as String
sFileName="文件名称"
wBook.SaveAs Application.CurrentProject.Path & "\" & sFileName, xlExcel7 '保存(xlExcel7为2003,xlExcel8为2007,xlCSV为csv文本,xlUnicodeText,xlTextWindows为文本,xlDBF3
建议改为
Dim exlApp As New Excel.Application '创建一个EXCEL程序实例
Dim wBook As Workbook '创建一工作簿实例
Dim sht As Worksheet '创建一个表单(Sheet)
set wbook=exlapp.workbooks.add '前面用了new关健字,所以不用建立excel.Application
Set sht = xlBook.Worksheets(1)
exlApp.Visible = True
dim sFileName as String
sFileName="文件名称"
wBook.SaveAs Application.CurrentProject.Path & "\" & sFileName, xlExcel7 '保存(xlExcel7为2003,xlExcel8为2007,xlCSV为csv文本,xlUnicodeText,xlTextWindows为文本,xlDBF3
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim exlapp As Object
Dim wbook As Object
Dim sht As Object
Set exlapp = CreateObject("excel.Application")
Set wbook = exlapp.Workbooks.Add
Set sht = wbook.sheets(1)
exlapp.Visible = True
End Sub
这样即可
Dim exlapp As Object
Dim wbook As Object
Dim sht As Object
Set exlapp = CreateObject("excel.Application")
Set wbook = exlapp.Workbooks.Add
Set sht = wbook.sheets(1)
exlapp.Visible = True
End Sub
这样即可
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询