invoke "Save Changes?" prompt

G

Guest

Hi everyone,
I would like to invoke the "save changes?" prompt message that normally
appears when you are closing a workbook or the application.
I've searched through the xlDialogs and can't seem to find the exact prompt
- I don't want a prompt that allows SaveAs capability.
How can I invoke this dialog in VBA?
Thanks in advance guys!
 
L

Leith Ross

Hello I Beliieve,

Here is macro that recreates the dialog. Another choice would be to add
this into your code...

ActiveWorkbook.Saved = False
Application.Quit

HERE'S THE DIALOG IN MACRO FORM...

Code:
--------------------

Sub SaveChangesPrompt()

Dim Answer

Answer = MsgBox("Do you want to save the changes you made to '" & ActiveWorkbook.Name & "'?", vbExclamation + vbYesNoCancel)

Select Case Answer
Case vbYes
ActiveWorkbook.Save
Case vbNo
ActiveWorkbook.Saved = True
Application.Quit
Case Cancel
Exit Sub
End Select

End Sub
 
G

Guest

Thanks Leith.
My next problem would have been to capture the user's selection but I can
easily do this now with the sub you provided.

Cheers!
 

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