Micro Focus QTP (UFT) Forums
Help with SaveAs method - 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: Help with SaveAs method (/Thread-Help-with-SaveAs-method)



Help with SaveAs method - mv8167 - 03-30-2012

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