Set reference to a type library
Automation (formerly OLE Automation) enables you to use objects from other applications in Visual Basic code. An application that provides its objects for use by other applications also provides information about those objects in a type library. To achieve the best possible performance when using another application's objects, you should set a reference to that application's type library.
To set a reference to an application's type library
Choose References on the Tools menu.
Select the check boxes for the applications with type libraries that you want to reference.
If you are writing code that manipulates objects in another application, you should set a reference to that application's type library for best possible access to those objects. You don't have to set a reference to use another application's objects, but doing so provides several advantages for your application.
Your code will run faster if you set a reference to another application's type library before you work with its objects. If you set a reference, you can declare an object variable representing an object in the other application as its most specific type. For example, if you are writing code to work with Microsoft Excel objects, you can declare an object variable of type Excel.Application if you created a reference to the Excel type library.
The following code is the fastest way to create a variable to represent the Excel Application object.
Dim appXL As Excel.Application
Dim appXL As Object
If you set a reference to an application's type library, all of its objects and their methods and properties are listed in the Object Browser. This makes it easy to determine what properties and methods are available to each object.
For Microsoft applications that can also serve as Automation servers, you can set references to their type libraries from another application, and control their objects from that application.
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.