Supress SaveAs dialog box?

  • Thread starter Thread starter Ed
  • Start date Start date
E

Ed

I have
Application.DisplayAlerts = False
Application.EnableEvents = False
wb.SaveAs strFName
Application.EnableEvents = True
Application.DisplayAlerts = True

DisplayAlerts suppresses the message that I'm overwriting a file, but will
not keep the SaveAs dialog box from popping up. I'm using XL2000, SP-3.
Any suggestions? Do I have to work through the DIalogs collection and kill
that one if it comes up?

Ed
 
The code you show does not cause the SaveAs dialog to show. suspect you
have this in the BeforeSave event. If so, you need to add

Cancel = True
 
Ed said:
I have
Application.DisplayAlerts = False
Application.EnableEvents = False
wb.SaveAs strFName
Application.EnableEvents = True
Application.DisplayAlerts = True

DisplayAlerts suppresses the message that I'm overwriting a file, but will
not keep the SaveAs dialog box from popping up. I'm using XL2000, SP-3.
Any suggestions? Do I have to work through the DIalogs collection and kill
that one if it comes up?

Ed

You can use the saved property like below

Sub CloseWithoutChanges()
ThisWorkbook.Saved = True
ThisWorkbook.Close
End Sub
Best Regards,Fredrik
 
You are correct, Tom (as usual!). And, again, I owe you great thanks for
your help.

So it must be something about being in the Save event already, and then
invoking it again, but I'm only dealing with the one I invoke, rather than
the one I initiated to get into the event(?).

Ed
 
the dialog is from the one you initiate manually - remember this is the
BeforeSave event. So when your code completes, the original save you
initiate puts up the dialog. Setting Cancel = True cancels the processing
of the initial triggering event.
 
Back
Top