| < Free Open Study > |
|
The Documents collection contains all of the Document objects in the IDE. Each object represents an open document. You can reference all of the open documents by looping through the Documents collection. Executing the code sample in Listing 5-1 in an add-in closes all open documents that have been previously saved.
Note | When DTE is the parent object in sample code, and I am discussing code within an add-in, I will always use the application object and substitute the variable name oVB for DTE.You will remember from Chapter 3 that I used oVB as ashort name for the application object. DTE will be used as the real object when I discuss code examples in Chapter 8. |
Listing 5-1: Closing Saved Documents
' Close all saved documents. Dim i As Integer With oVB Try For i = 1 To .Documents.Count If .Documents.Item(i).Saved Then .Documents.Item(i).Close() End If Next I Catch ' Ignore any error we raise attempting to close End Try End With
| < Free Open Study > |
|