Copy link to clipboard
Copied
Hi,
I have an Event calling a VBS script using the javascript below and want to pass the Event (or the parent of the Event - the document) to the VBS.
myScript = "c:/test.vbs";
app.doScript(myScript, ScriptLanguage.visualBasic,[myEvent]);
However, my simple VBS script does not display anything.
rem test.vbs script
msgbox myEvent
I have tried just passing a string through as a variable but no luck.
myVariable = "Hello World";
myScript = "c:/test.vbs";
app.doScript(myScript, ScriptLanguage.visualBasic,[myVariable]);
rem test.vbs script
msgbox myVariable
I am sure this should be simple but the only info I can find online is to do with javascript and vbs in HTML and ASP.
Thanks for any help.
Simon.
Copy link to clipboard
Copied
Don't pass it.
Save it as an environment variable or save the variable to a file.
Harbs
Copy link to clipboard
Copied
Thanks Harbs,
I had thought of writing a file but environment variable sound interesting.
Are we talking about something like...
$.setenv("myVariable","Hello World")
alert($.getenv("myVariable"))
Any idea how to retrieve an environment variable in vbs?
Copy link to clipboard
Copied
This seems to work in vbs...
Set WshShell = CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("Process")
msgbox objEnv("myVariable")
Thanks for your assistance.
Simon.
Copy link to clipboard
Copied
Hi Skempy,
Like this:
myVariable = ["Hello World"];
myScript = "c:/test.vbs";
app.doScript(myScript, ScriptLanguage.visualBasic,myVariable);
rem test.vbs script
msgbox arguments(0)
Thanks,
Ole
Copy link to clipboard
Copied
I'm pretty sure your VBScript will only be passed the value of the myEvent variable, not the variable itself. For this reason you will not be able to access the variable by name. There may be a better way but in JavaScript the easiest way is probably to access the arguments through the appropriately named property arguments (an array). Possibly something similar is available in VBScript as well?
I am kinda doubtful you'll be able to pass JavaScript objects as arguments to a VBScript though. Since it seems like what you're after is just the active document, is probably safer to just pass the id or index (as a number) of the document rather than an object reference to the document.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more