Microsoft Office 2000/Visual Basic Programmer's Guide   

Working with the Application Object

Every time you write VBA code in Word, or write code to automate Word from some other application, you begin with the Application object. If you are working in Word, the Application object is created for you and you can use the Application property to return a reference to the Word Application object. If you are automating Word from some other application, you must create a Word Application object variable and then create an instance of Word.

From the Application object, you can access all the other objects exposed by the application as well as properties and methods unique to the Application object itself. For information about using other objects exposed by the Word Application object, see "The Document Object" later in this chapter.

To access properties and methods of the Application object, you use the following syntax:

Application.PropertyName

Application.MethodName (arg1, arg2, argN)

You can access child objects of the Application object by using the following syntax:

Application.ObjectName

–or–

ObjectName

You don't need to use the Application property in this context because these objects are global. To see an application's global members, open the Object Browser and click <globals> in the Classes list. The global items will be displayed in the Members of list.

To see examples of accessing properties and methods of the Application object, see the ApplicationObjectExample procedure, which is available in the modApplicationObject module in WordOptions.doc in the ODETools\V9\Samples\OPG\Samples\CH05 subfolder on the Office 2000 Developer CD-ROM.