Hi jakopak,
The following may help you. I put 4 'double quotes' around each item that may contain an embedded space character.
Excel Macro Code:
Sub RunVBS()
Dim sFileName As String
Dim sPath As String
Dim sPathAndFileName As String
Dim p1 As String
Dim p2 As String
'Get the path
'Get the File Name
'Create the full path and file name
sPath = ThisWorkbook.Path & "\"
sFileName = "ExcelForumParameterTest.vbs" 'Put your file name here
sPathAndFileName = sPath & sFileName
'Define the Parameters to pass
p1 = "abc"
p2 = "Two Words"
sPathAndFileName = """" & sPathAndFileName & """"
p1 = """" & p1 & """"
p2 = """" & p2 & """"
Call Shell("wscript " & sPathAndFileName & " " & p1 & " " & p2, vbNormalFocus)
End Sub
Wscript Code (my file ExcelForumParameterTest.vbs):
' ExcelForumParameterTest.vbs
' Reference: http://ss64.com/vb/arguments.html
wscript.echo "The number of arguments is ", wscript.Arguments.Count
iCount = -1
For Each strArg in wscript.Arguments
iCount = iCount + 1
WScript.Echo "Argument(" & iCount & ") = ", strArg
Next
Lewis
Bookmarks