James Craig
James Craig

Reputation: 493

Calling a function in another file in VB Script

I am using a Test Driver script (testset Driver.vbs) in QTP and in it I am trying to call a function in another file. I thought I could add this to the testset driver.vbs:

Function IncludeAOA
Dim objFSO, objFile, AR1

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("\\Server1\QTP Files\Community\Driver Scripts\AOAReg.vbs", 1)
    AR1 = objFile.ReadAll
    objFile.Close
    ExecuteGlobal AR1
End Function

I call the IncludeAOA function which seems to work. But, when it gets to the ExecuteGlobal AR1 line it fails with an

Error: Invalid Character, Code: 800A0408.

Can anyone see what I missed?

Upvotes: 1

Views: 8001

Answers (1)

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38775

AR1 - i.e. the code in AOAReg.vbs - is to blame. Try to 'run' it with cscript AOAReg.vbs. If that does not show the error (including the line number), post the code or check the encoding of that file.

Upvotes: 3

Related Questions