Reputation: 1400
I have the following VBA:
Sub StartVbs(sVbsPathNmExt)
Shell "Explorer.exe """ & sVbsPathNmExt & """", 1
End Sub
And the following VBScript in ParamPassTest.vbs:
MsgBox("Hello x" )
WScript.quit
It displays a message "Hello x" when I call it like this from VBA:
Sub do_StartVbs()
Call StartVbs("Z:\somepath\ParamPassTest.vbs")
End Sub
How do I pass that "x" in from VBA to VBS as an argument?
I tried both methods here and they either error or cause my anti-virus to close everything down: passing argument from vba to vbs
Rather than loosen my anti-virus rules, how do I pass in a parameter to a vbs from vba?
Upvotes: 0
Views: 848
Reputation: 22876
You can try this in VBA:
Shell "WScript ""C:\path\1.vbs"" 123"
and this in 1.vbs:
If WScript.Arguments.Count > 0 Then MsgBox WScript.Arguments(0)
Upvotes: 2