K
kmbarz
I'm working with some test macros to try and get something real working.
Within VBA, I can call the test2 macro with a string parameter and
everything works:
Sub test2(LOSName)
MsgBox LOSName
End Sub
Sub test3()
test2 ("Hi")
End Sub
However, if I try the same thing from a command line going through my VBS
program, my double quotes are getting stripped away somewhere and I can't
pass in my parameter.
c:\> cscript.exe c:\CallExcelMacro.vbs c:\test.xls test2("Hi")
results in: CallExcelMacro.vbs(14,3) Microsoft Office Excel: The macro
'test2(Hi)' cannot be found.
Any ideas as to what the issue here is? Thanks. The vbs follows:
Option Explicit
Dim objArgs
Set objArgs = WScript.Arguments
Sub CallExcelMacro(strData, strMacro)
Dim objXL
'Dim strData
Set objXL = WScript.CreateObject("Excel.Application")
objXL.WorkBooks.Open strData
objXL.Visible = TRUE
objXL.Run(strMacro)
objXL.Quit
Set objXL = Nothing
End Sub
Call CallExcelMacro(objArgs(0), objArgs(1))
Within VBA, I can call the test2 macro with a string parameter and
everything works:
Sub test2(LOSName)
MsgBox LOSName
End Sub
Sub test3()
test2 ("Hi")
End Sub
However, if I try the same thing from a command line going through my VBS
program, my double quotes are getting stripped away somewhere and I can't
pass in my parameter.
c:\> cscript.exe c:\CallExcelMacro.vbs c:\test.xls test2("Hi")
results in: CallExcelMacro.vbs(14,3) Microsoft Office Excel: The macro
'test2(Hi)' cannot be found.
Any ideas as to what the issue here is? Thanks. The vbs follows:
Option Explicit
Dim objArgs
Set objArgs = WScript.Arguments
Sub CallExcelMacro(strData, strMacro)
Dim objXL
'Dim strData
Set objXL = WScript.CreateObject("Excel.Application")
objXL.WorkBooks.Open strData
objXL.Visible = TRUE
objXL.Run(strMacro)
objXL.Quit
Set objXL = Nothing
End Sub
Call CallExcelMacro(objArgs(0), objArgs(1))