WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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)
exit

Answer:

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:   W14696
Filename:   Get SaveAs to Close without Alert Box.txt
File Created: 2001:02:09:16:12:46
Last Updated: 2001:02:09:16:12:46