Micro Focus QTP (UFT) Forums
QTP and Excel - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: QTP and Excel (/Thread-QTP-and-Excel)



QTP and Excel - Sonia - 02-13-2008

I am using QTP 9.2 . I was trying to write a simple login script that takes a username and password. However instead of storing the parameters in the data table I woul dlike the script to pick up the data at run time from an Excel sheet.

I know we can import excel data into data table but I dont want to use fixed parameters. I would like to keep the script separate and update the excel file with new data .

How can I make my script take data from excel during run time .?


RE: QTP and Excel - Ankur - 02-13-2008

You need to use Automation Object Model(AOM)

try this code:

Code:
Dim filepath, sheet,row,column,value  
   filepath= "C:\qtp_test.xls"
   Set ExcelObj = CreateObject("Excel.Application")
   ExcelObj.Workbooks.Open filePath //opens the excel from desired path
   Set NewSheet = ExcelObj.Sheets.Item(sheet) //selects the sheet from workbook
   value = NewSheet.Cells(row,column) //gets the value of a specified cell
   ExcelObj.Application.Quit
   Set ExcelObj = Nothing
   msgbox value