How to get SaveAs to Close Excel without Warning Dialog
Keywords: saveas
Question:
I have the following code to save and close Excel, but a window comes up asking if I want to overwrite the currently existing file.How do I get rid of that window?
DB = ObjectOpen("Excel.Application") DB.DisplayAlerts =@FALSE ; this prevents the warning message from coming up oAPP = DB.Workbooks oAPP.Open("C:\WINDOWS\DESKTOP\test.XLS") oWKS = DB.Worksheets oWS = DB.Worksheets(1) oWS.Activate oWS.SaveAs(:: Filename="C:\WINDOWS\DESKTOP\test.XLS") ;note the oWS object here oAPP.close() ObjectClose(DB) exitAnswer:
Set the method, "DisplayAlerts", on the main OLE object, to FALSE, e.g.,DB = ObjectOpen("Excel.Application") DB.DisplayAlerts =@FALSE ; this prevents the warning message from coming up oAPP = DB.Workbooks oAPP.Open("C:\WINDOWS\DESKTOP\test.XLS") oWKS = DB.Worksheets oWS = DB.Worksheets(1) oWS.Activate oWS.SaveAs(:: Filename="C:\WINDOWS\DESKTOP\test.XLS") ;note the oWS object here oAPP.close() ObjectClose(DB)
Article ID: W14696Filename: Get SaveAs to Close without Alert Box.txt