The Documents Collection

As you no doubt know, Word 97 is a multiple document interface (MDI) application, meaning that more than one document can be open in a single instance of Word 97 at the same time. Each instance of Word 97 has its own Application object. Moreover, the Documents collection, which is a child of the Application object, contains a Document object for each open document in that instance of Word 97.

All this can be easily verified by opening two instances of Word 97, opening the VB editor for each instance, and executing the following code:

	Sub test()
	MsgBox Documents.Count
	End Sub

The results indicate that each instance of Word 97 has a separate Documents collection.

On the other hand, Word 2000 is different, and the difference can be very significant. For reasons that are not entirely clear to me, Word 2000 can best be described as a pseudo-single document interface application (how about PSDI?). In particular, when you open a second document in Word 2000, a second instance of Word is created and the document is placed in that instance. (Check the taskbar!) However, you can still switch between open documents using the familiar Window menu in any instance. Instead of just changing the active document, Word changes the active instance! (You can see this more clearly by changing the size of one of the instance’s main window.)

Now, the point is that under Word 2000, there appears to be only one Application object for all instances of Word. Indeed, if you open two instances ...

Get Writing Word Macros, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.