这段代码为什么会出错
请高手帮忙看看这段代码为什么会出错哪里有问题?
Dim xlapp As ObjectSet xlapp = CreateObject("Excel.Application")
xlapp.Visible = True
Dim xlbook As Object
Set xlbook = xlapp.Workbooks.Add
Dim xlmodule As Object
Set xlmodule = xlbook.VBProject.VBComponents.Add(1)
Dim strCode As String
strCode = "sub MyMacro()" & vbCr & _
" msgbox ""Inside generated macro!!!"" " & vbCr & _
"end sub"
xlmodule.CodeModule.AddFromString strCode
xlapp.Run "MyMacro"
xlbook.Saved = True
xlapp.Quit
第一行Dim xlapp As Object 是单独一行
其它错误暂且不说
Dim xlapp As ObjectSet xlapp = CreateObject("Excel.Application")分两行吧 还有添加Excel的DLL引用了么 哪一行出错,出什么错~~~
补充:VB , VBA