03-30-2012, 09:37 PM
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:
Any ideas on why?
thx
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