QTP – createObject – read excel sheet

by Jeff Fillegar on September 14, 2010

Public Sub GetQTPConfig

Set xlApp = CreateObject(“Excel.Application“)

Set xlBook = xlApp.WorkBooks.Open(“C:\QTP\Config\qtpconfig.xls”)
Set xlSheet = xlBook.WorkSheets(“Sheet1”)
 
‘Retrieve local config settings
   sUserName = xlSheet.Rows(2).Columns(2).Value
   sPassword = xlSheet.Rows(3).Columns(2).Value
   sScriptPath = xlSheet.Rows(4).Columns(2).Value
   sEnv = xlSheet.Rows(5).Columns(2).Value
 
xlBook.Close
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End Sub

Leave a Comment

Previous post:

Next post: