Cancel save dialog box

S

Sandy

I have the following code which works fine except that the save dialog box
pops up.
Having already saved the workbook I do not want the save box to display -
how do I prevent it?

Private Sub xxxxx()
'stuff
ThisWorkbook.Save
Application.Quit
End Sub

TIA
Sandy
 
D

Dennis

It should not display another message. Have you got other workbooks open than
the one you are programmatically saving ?
You can stop the message by putting this before your quit statement

Application.DisplayAlerts = False
 
S

Sandy

Hi Dennis
There were no other books open; I was however doing a 'SaveAs' which was in
the code prior to 'ThisWorkbook.Save' so I suppose that might have had a
bearing - your suggestion works perfectly though.
Thank you.
Sandy
 
F

FSt1

hi
be sure to turn alerts back on before you exit the sub.
Application.displayalerts = true

Regards
FSt1
 
D

Dennis

Does this actually matter in this case because the next statement was
quitting the app ?
Won't they automatically be back on next time Excel is loaded ?
 
F

FSt1

hi
maybe not. but it's been my experience that the two commands always be used
togeather regardless ie just get in the habit of turning alerts back on just
in case.

Regards
FSt1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top