vb调用excel宏

2024-11-01 22:59:53
推荐回答(2个)
回答1:

Private sub Command3_Click()
Dim xlapp As Excel.Application
Dim xlbook As Excel.workbook
Dim xlsheet As Excel.worksheet
Dim appexcel As Object
Set xlapp = CreateObject("excel.application")
' 设要处理的表为你那个带宏的表 ----- Test.xls
Set xlbook = xlapp.workbooks.open(App.Path & "\Test.xls")
xlapp.Visible = True '使你的表可见
xlapp.run "aa"
End sub
'经过测试,可以运行宏!

回答2:

因为自定义宏所在的文件都没打开。