Run macro before closing to prevent prompt to save document

thandel
thandel used Ask the Experts™
on
I would like to run a macro before a document is closed.... specifically I don't want Word to ask if they would like to save the document even if they made changes.  I tried

Sub Document_Closed ()
ThisDocument.Saved = True

but I still get prompted to save the document.

What did I do wrong?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Its all about where the call is located but try your macro as:

Sub AutoClose()

    ActiveDocument.Save

End Sub

Here is an explanation why this works

Scott

Author

Commented:
Thanks, is there a list I can find on the internet for items like this.

I updated your code to this so it simply closes... where it needs to be saved or not.

Sub AutoClose()

    ActiveDocument.Saved = True

End Sub

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial