My company recently "upgraded" our terminal software. This software embeds a SAX/WinWrap IDE to create custom programs and macros to use with the software, which is extremely similar to VBA - just without the references to the specific programs (Word, Excel, etc). Because a VBA solution will work is the reason I tagged this as VBA (WinWrap is not popular at all and would never draw any attention).
Unfortunately in this "upgrade", the IDE can only support so many lines within the module or else the module simply just will not load. I am now wanting to rewrite some of these programs to run within a VBScript file, but a major hurdle is passing object variables. This program uses Session objects that are important for the majority of the programs we use, but I am not sure if it's even possible to pass these objects to the vbscript.
I know you can pass a string variable to a VBS file in the following manner:
Shell "wscript C:\Sripts\" & ScriptName & ".vbs StrArg1 StrArg2"
And within the vbs file you can use the following code to retrieve these arguments:
Dim Arg1, Arg2
Arg1 = Wscript.Arguments(0)
Arg2 = Wscript.Arguments(1)
However, this only works for string arguments. It's passed literally and is not even a ByRef
/ByVal
variable.
I have attempted using the Run()
function:
Dim Ses As Session
Set Ses = ActiveSession ' Think of ActiveSession being similar to ActiveSheet within VBA
Run "C:\Scripts\test.vbs", Ses
But it failed (as expected) giving an Exception 800a03ec with no error description. What, if anything, can be done to pass an object to a vbs file?