Early Binding

The other—and now most common—method of adding an object reference to your project is by using the References dialog, which is shown in Figure 5-1. You can access the References Dialog by selecting the References option from the Project Menu. All OLE Automation Servers registered on your machine are shown in the list. To create a reference to one of them, check the box and click OK.

Once you have added a reference to your project in this manner, you can create an early bound interface to the object by using the Private, Public, Friend, or Dim statement to declare an object variable of the exact type. Then use the Set statement to assign an object reference to the local variable. (For details on how to use the Private, Public, Friend, Dim, and Set statements, see their entries in Chapter 7.) For example:

Dim objDoc as Document

Set objDoc = Word.Application.ActiveDocument

You can also use the New keyword with the Private, Public, Friend, or Dim statement, as in the following example:

Dim objDoc As New Document

78 Chapter 5 - Automation

References - Project!

Available References:

✓ Visual Basic For Applications

>/ Visual Basic runtime objects and procedures y Visual Basic objects and procedures

AccountLib Type Library

Active DS IIS Namespace Provider

Active DS Type Library

Active Setup Control Library

ActiveMovIe control type library

Addln Designer/Instance Control Library

APE Database Setup Wizard

API Declaration Loader

AoDllcatlon Performance Exolorer Client

Was this article helpful?

0 0

Post a comment