Closing a Document Without Saving in Word 2007

Microsoft Word, Tips & Tricks Add comments

mswordtweak.pngIt’s occasionally convenient to close a document without saving your changes. For example, you might create a new document to use as a scratch pad or to test out a new feature. Similarly, you might open an existing document, make some temporary changes, and then close the document without saving those changes. In each case, when you choose Office, Close, Word asks if you want to save the document. This not only slows you down by requiring an extra step that you don’t need, but there’s also the real danger that you might click Yes by accident.

To work around these problems, I use a macro that automatically closes a document with­out saving any changes and without prompting to save changes. Listing 1 shows the macro.

Listing 1 A Macro That Closes a Document Without Saving ChangesA Macro That Closes a Document Without Saving Changes

As you can see, this is a simple procedure that runs only the ActiveDocument object’s Close method with the SaveChanges argument set to the constant value wdDoNotSaveChanges.

A more involved example is shown in Listing 2.

Listing 2 A Macro That Closes a Document Without Saving Changes and Then Reopens the Document

A Macro That Closes a Document Without Saving Changes and Then Reopens the Document

This macro first uses various properties of the ActiveWindow object to save the document’s current window state, position, and dimensions. Then the code saves the document’s full path name (as given by the FullName property), and the document is closed without saving changes. The Open method reopens the document, and then the window is restored to its former state, position, and dimensions.

CAUTION

Be sure to move the CloseAndReopen macro to a document other than the one that you’ll be closing and reopening. (For example, you could store it in the Normal template.) Otherwise, when the document is closed, the code module is closed along with it, so the document can’t reopen.

Technorati Tags: ,

Popularity: 3% [?]

Related Post

  • Closing All Your Open Documents in Word 2007
  • Microsoft Office Word Hot Tips
  • Inspecting a Document for Personal Information in Word 2007
  • Automatically Saving Your Work Frequently in Word 2007
  • Recovering More of Your Work with a Shorter AutoRecover Interval in Word 2007
  • Don't Find What You're Looking For? Please Try Here...

    Google
     

    Leave a Reply

    WP Theme & Icons by N.Design Studio
    Entries RSS Comments RSS Add to Technorati Favorites Log in