Micro Focus QTP (UFT) Forums
I want to store result in exce sheet - 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: I want to store result in exce sheet (/Thread-I-want-to-store-result-in-exce-sheet)



I want to store result in exce sheet - Ragini - 12-28-2010

Hi all.......I am facing one problem.This is my script.


Code:
a=window("Flight Reservation").WinButton
("Insert Order").CheckProperty("enabled",false,1000)
If a=true then
window("Flight Reservation").WinEdit("Name:").Set "Ragini"
b=window("Flight Reservation").WinButton
("Insert Order").CheckProperty("enabled",true,1000)
msgbox "disable"
msgbox "enable"
End If


Now I want to store the result in excel sheet.please anyone help me...


RE: I want to store result in exce sheet - yagarules - 12-29-2010

Which Result do you want to store???, enable or disable???, maybe you can send those results to an excel sheet, read the article QTP and Excel, to get output values to your script, maybe and then export Datatable with the instruction DataTable.ExportSheet,


RE: I want to store result in excel sheet - Ragini - 12-29-2010

Hi yagarules..........Output values i can get from application ..........Here I want to store both results "diabled" and "enabled" from my script.......


RE: I want to store result in exce sheet - joe.venom13 - 12-29-2010

Hi,

You can use the following code to store the data in excel:

Code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = False
Set objWorkbook = objExcel.WorkBooks.Open("path of the file.xls")  'this is the name of the excel file
Set objDriverSheet = objWorkbook.Worksheets("Sheet1")  'this is the sheet name in the excel file

columncount = objDriverSheet.usedrange.columns.count
rowcount = objDriverSheet.usedrange.rows.count
i = rowcount

If rowcount = 1 Then
   objWorkbook.Sheets("Sheet1").Cells(i,1).Value = a
   objWorkbook.Sheets("Sheet1").Cells(i,2).Value = b
Else
   i = i+1
   objWorkbook.Sheets("Sheet1").Cells(i,1).Value = a
   objWorkbook.Sheets("Sheet1").Cells(i,2).Value = b
End If

objWorkbook.Save
objWorkbook.Close
objExcel.Quit