Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTP and Excel
#1
Solved: 11 Years, 3 Months, 1 Week ago
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 .?
Reply
#2
Solved: 11 Years, 3 Months, 1 Week ago
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
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  excel macro to open QTP from excel karthik1979_us 1 11,076 11-07-2009, 02:57 AM
Last Post: geethwind

Forum Jump:


Users browsing this thread: 1 Guest(s)