I am trying to call a VBScript file from an Excel VBA Macro. The VBScript has named arguments.
My VBScript is as follows.
dim argument1
argument1 = WScript.Arguments.Named.Item("argument1")
if argument1 = "" then
WScript.Echo "No filepath provided. Aborting."
WScript.Quit
end if
WScript.Echo "Launching Excel..."
dim excelInstance
set excelInstance = CreateObject("Excel.Application")
dim Application
set Application = excelInstance.Application
excelInstance.Visible = false
Application.ScreenUpdating = false
WScript.Echo "Opening Excel file..."
dim File1
set File1 = OpenWorkbook(excelInstance, argument1)
My Excel VBA Macro is as follows.
Sub CreateOutput()
Dim filePath, fileDir, shellCommand, vbScriptPath
fileDir = ThisWorkbook.Path
filePath = fileDir & "\exampleFile.xlsx"
vbScriptPath = fileDir & "\VBScript1.vbs"
shellCommand = vbScriptPath & " " & Chr(34) & filePath & Chr(34)
Set wshShell = CreateObject("Wscript.Shell")
wshShell.Run """" & shellCommand & """"
End Sub
Upon executing the Macro I am getting a popup with the message "No filepath provided. Aborting." Any suggestions on how to pass the path to exampleFile.xlsx as a named argument?