07-13-2011, 12:57 AM
My code below works except for the Save code. The SaveAs is good and works fine.
Can someone tell me what I need to change? thx
My code:
Can someone tell me what I need to change? thx
My code:
Code:
Public Function SaveOrSaveAsExcelSheet (FilePath)
Set objFso = CreateObject("Scripting.FileSystemObject")
'Check if file already Exists
bFileExist = objFso.FileExists(FilePath)
If bFileExist Then 'SaveAs - Use the SaveAs method as the file has been saved
'objExcel.Workbooks.SaveAs (FilePath)
objExcel.ActiveWorkBook.SaveAs (FilePath)
Else 'Save - Use the Save method as the file has never been saved
objExcel.ActiveWorkbooks.Save '(FilePath)
End If
objExcel.Visible = False
objExcel.DisplayAlerts = False
objExcel.Quit
Set objExcel=Nothing
Set objFso=Nothing
End Function