I am executing VBS files from VBA using Wscript.Shell and passing some arguments to VBS. Now, I want the Wscript.Shell wait for the return of the arguments/variable from VBS. Any lead, how do I achieve this? Thanks
VBA code is:
Sub LaunchScript()
Dim wsh As Object
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1
Dim scriptPath As String, MyMsg As String
Dim Return_VBS_Val
scriptPath = "C:\path\x.vbs"
MyMsg = "I got into VBS"
Set wsh = VBA.CreateObject("WScript.Shell")
wsh.Run """" & scriptPath & """ """ & MyMsg & """", windowStyle, waitOnReturn
'Return_VBS_Val = argument from x.vbs >>>>> I want to pull the argument from VBS here and store it in this VBA Variable
End sub
x.vbs code:
Dim Return_VBS_Val
'something to do here
Msgbox Wscript.Arguments(0)
Return_VBS_Val = "Hello VBA"