Wednesday, October 10, 2007

How to load vbs file dynamically to QTP?

Public Sub Imports( ByVal fullFileNameStr )
Const ForReading = 1
Dim oFileDim
ReadAllTextFile
On Error Goto 0

If fullFileNameStr = vbNullstring Then
Reporter.ReportEvent micFail, “FileNotFoundException”, “Unable to find the specified file: ” & libName
Exit Sub
End If
Set oFile = FsoUtil.OpenTextFile( fullFileNameStr, ForReading )

ReadAllTextFile = oFile.ReadAll()
oFile.Close : Set oFile = Nothing

‘ ** Executing the text, to load file to memory.
ExecuteGlobal( ReadAllTextFile )

End Sub

Call the function as the follows

Imports “C:\Automation\MyFile.vbs”

No comments: