I want to catch the "Save on Exit" routine

J

JeffG

I need to take an action when the user presses the X in the upper right
corner on a document that has been modified but not saved. Preferably, I
would like to do this after the Word query to save or not has been answered
with a yes.

Could anyone show me how to accomplish this?
 
G

Graham Mayor

There is no way to force this on a user as it requires macros and you cannot
force a user to run macros if he chooses not to. However you could add an
autoclose macro to the document template to force a save if the document in a
loop that will continue until the document is saved:

Sub AutoClose()
Start:
If Not ActiveDocument.Saved Then
Dialogs(wdDialogFileSaveAs).Show
If Not ActiveDocument.Saved Then
MsgBox "Document must be saved before closing!"
GoTo Start
End If
End If
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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