O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required