Monday 16 July 2012

How to load library files without setting in QTP

Work without QTP for loading the library files and picked the current path automatically.
'===================================================
    'How to work without QTP with excel and load the vb library without using the QTP tool
    set wshell = createobject("wscript.shell")  
                        CurrentPath =  wshell.currentdirectory    
                        DFA_DFA_Dictionary= CurrentPath & "\DFA_Library\DFA_Dictionary.ini"  
                        DFA_SummaryResult_Library = CurrentPath & "\DFA_Library\DFA_SummaryResult.ini"                         


                                                    AddLibrary DFA_DFA_Dictionary  ' to add library during execution using vbs script        
                                                    AddLibrary DFA_SummaryResult_Library  ' to add library during execution using vbs script     

Function AddLibrary(FileName)
                Dim fsObj : Set fsObj = CreateObject("Scripting.FileSystemObject")
                Dim vbsFile : Set vbsFile = fsObj.OpenTextFile(FileName, 1, false)
                Dim myFunctionsStr : myFunctionsStr = vbsFile.ReadAll
                ExecuteGlobal myFunctionsStr
                vbsFile.Close
                Set vbsFile = Nothing
                Set fsObj = Nothing
End function

No comments:

Post a Comment