4.1 Word s object model

Word s object model

The key object in Word is Document, which represents a single, open document. The Word server has a Documents collection, which contains references to all open documents. The server also has an ActiveDocument property that points to the currently active document.

The Document object has lots of properties and methods. Many of its properties are references to collections such as Paragraphs, Tables, and Sections. Each of those collections contains references to objects of the indicated type. Each object contains information about the appropriate piece of the document. For example, the Paragraph object has properties like KeepWithNext and Style, as well as methods like Indent and Outdent.

The Word server object, called Application, has its own set of properties and methods, including a number of other collections. In addition to ActiveDocument, the Application object s properties include Visible, StartupPath, Version, and WindowState. The Application object also has methods. The simplest to understand is Quit, which shuts down the server. It has several optional parameters the first indicates what to do if any open documents have been changed but not saved. Other methods of the Application object convert measurements from one set of units to another, check grammar and spelling, and much more.

Word Visual Basic Help contains a diagram of Word s object model. The figure is "live" when you click on an object, you re taken to the Help topic for that object. Figure 1 shows the portion of the object model diagram that describes the Document object.

 

Copyright 2000 by Tamar E. Granor and Della Martin All Rights Reserved



Microsoft Office Automation with Visual FoxPro
Microsoft Office Automation with Visual FoxPro
ISBN: 0965509303
EAN: 2147483647
Year: 2000
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net