Document Not Saved Error in Excel.
- by Sowmya
This is my code snippet for comparing 2 excel files. I call this function from my QTP scripts. I get this error quite often which causes my test script to fail. Any pointers will be appreciated.
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Visible = False
objExcel.DisplayAlerts = False
Set objWorkbook1= objExcel.Workbooks.Open(excelFile1)
Set objWorkbook2= objExcel.Workbooks.Open(excelFile2)
Set objWorksheet1= objWorkbook1.Worksheets(1)
Set objWorksheet2= objWorkbook2.Worksheets(1)
<Code that compares the 2 files & marks the cell in red where there is a mismatch)
objWorkbook2.Save
ERROR MESSAGE:
Document not saved.
Function file: C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\ReusableFunctions.qfl
Line (33): "objWorkbook2.Save".