It is said that there are no stupid questions, but I think I may demonstrate the error of that statement.
I am so not a programmer that I am embarrassed to even be posting to this site, but desperation has made me swallow my pride.
I am currently running a VBScript as part of an automation scheme sequentially executing Excel, JS, and other routines.
I need to be able to define a variable in the VBS code that will be passed on to the JS. Typically this would be a file path. I have tried the following (but of course it does not work):
MyServerSideVariable = "c:\\XXXX.csv"
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run """list.js""", 6, True
set wshshell = nothing
var MyClientSideVariable = '<% =MyServerSideVariable%>';
var AB, AA;
var fso, f, f1, fc, s;
/* create AB object */
AB = new ActiveXObject("Broker.Application");
/* retrieve automatic analysis object */
AA = AB.Analysis;
/* load formula from external file */
/* run Explore*/
/* and display report */
AA.Export(MyClientSideVariable); /*<<THIS IS MY CONTRIBUTION*/
Also what is "list.js" or is that nothing to do with the current question?
Okay, firstly you will also need to get rid of the [CODEvar MyClientSideVariable = '<% =MyServerSideVariable%>';][/code]
Then you have anumber of choices. I think the easiest is to use a wsf file which can have both the VBS and the JS files included in it. You then can call the functions in one from the other. You have to make a couple of changes to wrap the code in functions though rather than just code that runs when it is hit.
Another way would be to write the variable to a file using the FileSystemObject. Then read it back from the js file.
I currently run the same JS code many times during a day with the only difference being the name of the file that is being saved to. My current state of ignorance thus requires me to keep and modify many instances of what is mostly the same code whenever I make a change. I am looking to pass variables from VBS (the initiating code) to JS so as to keep the code down to a minimum.
I'm afraid that I am somewhat at a loss even with your descriptions. For example, I don't see have (in your 3'rd example) anything gets passed to the client.