Word Macro: Closing All Documents Without Looping

I’ve described a Word VBA macro that closes all files.
Actually, we can close all files without looping.

Macro Example

Sub ClosingAllFilesWithoutLoop()
 
  Documents.Close

End Sub

Description

We need only the following code:

  Documents.Close

That’s all.

The Application.Documents property returns the Documents collection object.

obj-Word-Application-Documents

The Documents property is a member of the Word.Global class, so we can omit the Application property.

obj-Word-Documents

The Documents is a collection of all the Document objects those are currently open in Word.

obj-Word-Documents

The Documents collection object has the Close method.

obj-Word-Documents-Close

And this Documents.Close method allows us to close all files without looping.

Properties

http://www.relief.jp/itnote/archives/word-macro-close-all-documents.php

Apply To

  • Word 2013
  • Word 2010
  • Word 2007