Home > Articles > Home & Office Computing > Microsoft Applications

This chapter is from the book

Closing All Your Open Documents

Later in this chapter, you learn how to create workspaces—collections of Word documents that you open as a unit. Before you open a workspace, it's a good idea to close all your open documents. You might also want to close all your open documents to get a fresh start with Word. In previous versions of Word, you can do this by holding down the Shift key, pulling down the File menu, and then selecting the Close All command. Unfortunately, that trick does not work in Word 2007. The other alternative is to shut down and restart Word, but that's often time-consuming. A faster method is to use the macro in Listing 3.4.

Listing 3.4. A Macro That Closes All Open Documents

Sub CloseAllOpenDocuments()
    Dim doc As Document
    For Each doc In Documents
        doc.Close
    Next 'doc
End Sub

This macro runs through the Document objects that are in the Documents collection, which holds all the documents that are currently open in Word. For each document, the macro runs the Close method without any arguments, which means that Word will prompt you to save changes.

  • + Share This
  • 🔖 Save To Your Account