Documents Collection Object
Word Developer Reference |
A collection of all the Document objects that are currently open in Word.
Remarks
Use the Documents property to return the Documents collection. The following example displays the names of the open documents.
Visual Basic for Applications |
---|
|
Use the Add method to create a new empty document and add it to the Documents collection. The following example creates a new document based on the Normal template.
Visual Basic for Applications |
---|
|
Use the Open method to open a file. The following example opens the document named "Sales.doc."
Visual Basic for Applications |
---|
|
Use Documents(Index), where Index is the document name or index number to return a single Document object. The following instruction closes the document named "Report.doc" without saving changes.
Visual Basic for Applications |
---|
|
The index number represents the position of the document in the Documents collection. The following example activates the first document in the Documents collection.
Visual Basic for Applications |
---|
|
The following example enumerates the Documents collection to determine whether the document named "Report.doc" is open. If this document is contained in the Documents collection, the document is activated; otherwise, it is opened.
Visual Basic for Applications |
---|
|
See Also