11-03-2010, 05:06 PM
Kavitha,
Thank you so much for the reply. Here probably, the problem is , when i run the script in the invisible mode, then it is throwing this error. But if i run the script from QTP UI, it is not working. I am copying the code here for your reference. Please have a look.
Thanks
Sasi.C
Thank you so much for the reply. Here probably, the problem is , when i run the script in the invisible mode, then it is throwing this error. But if i run the script from QTP UI, it is not working. I am copying the code here for your reference. Please have a look.
Code:
public Function Export_Result(TestID,Driver_Script,Res,Comments)
Dim objExcel,objBook,objSheet,i,columnCount,rowCount
' Initializing the Excel sheet
Set objExcel = CreateObject("Excel.Application")
Set objBook = objExcel.Workbooks.Open("Q:\Automation\Reports\Results.xls")
Set objSheet=objBook.Worksheets("Test_Results")
'Getting the TimeStamp
ResultTime=now
' Getting the used rows range
rowCount=objSheet.usedrange.rows.count
' Writing in Excel Sheet
objExcel.Worksheets("Test_Results").Cells(rowCount+1, 2).Value = TestID
objExcel.Worksheets("Test_Results").Cells(rowCount+1, 3).Value = Driver_Script
objExcel.Worksheets("Test_Results").Cells(rowCount+1, 4).Value = Res
objExcel.Worksheets("Test_Results").Cells(rowCount+1, 4).Font.Bold = true
If ucase(Res) = "PASS" Then
objExcel.Worksheets("Test_Results").Cells(rowCount+1, 4).Font.ColorIndex = 10
else
objExcel.Worksheets("Test_Results").Cells(rowCount+1, 4).Font.ColorIndex = 3
End If
objExcel.Worksheets("Test_Results").Cells(rowCount+1, 6).Value = ResultTime
'Writing the Comments
objExcel.Worksheets("Test_Results").Cells(rowCount+1, 5).Value = Comments
Export_Result = true
' Saving and closing the work book
objBook.Save
objExcel.Workbooks.Close
objExcel.Quit
End Function
Thanks
Sasi.C