VB 如何调用EXCEL VBA带参过程
我做了一个程序,用VB调用VBA进行处理数据处理,VBA是个带参数的过程,如果在外部用VB调用?...
我做了一个程序,用VB调用VBA进行处理数据处理,VBA是个带参数的过程,如果在外部用VB调用?
展开
1个回答
2013-08-06
展开全部
Set xlsApp = Nothing
/*----------有参调用模式-------------*/
xls文件中代码如下:
Sub test2(str As String)
MsgBox (str)
End Sub
VB代码如下:
Dim xlsApp As Excel.Application
Dim xlsBook As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
Set xlsApp = New Excel.Application
Set xlsBook = xlsApp.Workbooks.Open(App.Path + "\test.xls")
Set xlsSheet = xlsBook.Worksheets(1)
xlsApp.Visible = False
Call xlsApp.Run("test2", "Hello!World!")
/*----------有参调用模式-------------*/
xls文件中代码如下:
Sub test2(str As String)
MsgBox (str)
End Sub
VB代码如下:
Dim xlsApp As Excel.Application
Dim xlsBook As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
Set xlsApp = New Excel.Application
Set xlsBook = xlsApp.Workbooks.Open(App.Path + "\test.xls")
Set xlsSheet = xlsBook.Worksheets(1)
xlsApp.Visible = False
Call xlsApp.Run("test2", "Hello!World!")
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询