Micro Focus QTP (UFT) Forums

Full Version: Help with SaveAs method
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
On my SaveAs line, I get a Run Error of :

SaveAs method of Workbook class failed

Function file: O:\QTP Tests\NightlyRegressionTesting\Tests\LibraryImageAccessFunctions.qfl
Line (1250): " objExcel.ActiveWorkbook.SaveAs(FilePath) 'Use the SaveAs method if the file has never been saved before"

My code:

Code:
Public Function SaveOrSaveAsExcelSheet (FilePath, objExcel)

Set objFso = CreateObject("Scripting.FileSystemObject")

bFileExist = objFso.FileExists(FilePath)

objExcel.Visible = True
objExcel.DisplayAlerts = False

If Not bFileExist Then
      objExcel.ActiveWorkbook.SaveAs(FilePath) 'ERROR ON THIS LINE
Else
      objExcel.ActiveWorkbook.Save
End If

objExcel.DisplayAlerts = True
objExcel.ActiveWorkbook.Close
objExcel.Quit
Set objExcel=Nothing
Set objFso=Nothing

End Function

Any ideas on why?

thx