求帮看VB程序:导入EXCEL表格,但出现错误13
PrivateSubCommand1_Click()IfDir("d:\temp\excel.bz")=TrueThenSetxlapp=CreateObject(Exc...
Private Sub Command1_Click()
If Dir("d:\temp\excel.bz") = True Then
Set xlapp = CreateObject(Excel.Application)
xlapp.Visible = True
Set xlbook = xlapp.Workbooks.Open("d:\temp\bb\xls")
Set xlsheet = xlbook.Worksheets(1)
xlsheet.Activate
xlsheet.Cells(1, 1) = "abc"
xlbook.RunAutoMacros (xlAutoOpen)
Else
MsgBox ("excelyidakai")
End If
End Sub
Private Sub Command2_Click()
If Dir("d:\temp\excel.bz") <> "" Then
xlbook.RunAutoMacros (xlAutoClose)
xlbook.Close = True
xlapp.Quit
End If
Set xlapp = Nothing
End
End Sub
Private Sub Form_Load()
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim vbexcel As Object
End Sub
总是出现“错误13”,求帮助,跪谢! 展开
If Dir("d:\temp\excel.bz") = True Then
Set xlapp = CreateObject(Excel.Application)
xlapp.Visible = True
Set xlbook = xlapp.Workbooks.Open("d:\temp\bb\xls")
Set xlsheet = xlbook.Worksheets(1)
xlsheet.Activate
xlsheet.Cells(1, 1) = "abc"
xlbook.RunAutoMacros (xlAutoOpen)
Else
MsgBox ("excelyidakai")
End If
End Sub
Private Sub Command2_Click()
If Dir("d:\temp\excel.bz") <> "" Then
xlbook.RunAutoMacros (xlAutoClose)
xlbook.Close = True
xlapp.Quit
End If
Set xlapp = Nothing
End
End Sub
Private Sub Form_Load()
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim vbexcel As Object
End Sub
总是出现“错误13”,求帮助,跪谢! 展开
2个回答
展开全部
第二句: If Dir("d:\temp\excel.bz") = ""Then
另外:
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim vbexcel As Object
这些变量放到所有代码过程前面定义,这样才能在其他过程使用。
另外:
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim vbexcel As Object
这些变量放到所有代码过程前面定义,这样才能在其他过程使用。
更多追问追答
追问
试了试出现了这个错误:错误429activex部件不能创建对象
追答
说你想要做什么吧。你的代码没救了。
2015-07-07
展开全部
试试在CreateObject里面那个加双引号
追问
不行啊,还是错误13
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |