For Example... If i have two vbs files named, File1.vbs and File2.vbs
In File1.vbs there are two sub/function as hello(), welcome() and In File2.vbs there is sample() is a function... Now i want to call the sub welcome() from File1.vbs into File2.vbs sample() function.
Answer by rajesh · Jan 16, 2015 at 11:50 AM
Yes it is possible to call any sub procedures from one vbs to other vbs file It is possible using "ExecuteGlobal" Statement
Below is the demo code ..
The contents of Demo1.vbs
SUB A() MsgBox "SUB A CALLED" END SUB SUB B() MsgBox "SUB B CALLED" END SUB
Now as in your question if i need to call Sub procedure B() It can de done by the following code
'Demo2.vbs Dim fsObj Dim vbsFile Dim myFunctionsStr Set fsObj = CreateObject("Scripting.FileSystemObject") Set vbsFile = fsObj.OpenTextFile("C:\Demo1.vbs", 1, False) myFunctionsStr = vbsFile.ReadAll vbsFile.Close Set vbsFile = Nothing Set fsObj = Nothing ExecuteGlobal myFunctionsStr B() ' You can call the required Sub Procedure from Demo1.vbs
Is it possible to write a VB Script that will read the path of application in the Outlook email received by a particular sender or a subject and copy it to a designated location in the hard drive ? 1 Answer
No script debugger in UFT 5 Answers