How to: Reference COM and .NET Framework Components in Macros

Visual Studio macros can reference only .NET Framework components. To reference COM components, you must first import them using a tool called TLBIMP. TLBIMP "wraps" the component, enabling Visual Studio macros to reference it.

Reference a .NET Component

To reference a .NET Framework component

  1. In the Macros IDE, choose Add Reference on the Project menu. This displays the Add Reference dialog box.

  2. In the Add Reference dialog box, choose a component in the list and then choose Select.

Reference a COM Component

The list of components in the Add Reference dialog box includes all components installed by the .NET Framework, plus all private modules that you place in the ...\Microsoft Visual Studio 9\Common7\IDE\PublicAssemblies directory.

To import a COM component and then reference it in the Macros IDE

  1. In a command prompt, run TLBIMP on the COM component you want to import.

    Tip

    TLBIMP is a command line command located in ...\Program Files\Microsoft SDKs\Windows\v6.0A\Bin. To use it, you must run it in a DOS prompt window, specifying the complete path of the COM component you want to import. For details on TLBIMP and how to use it to import a COM type library, see Type Library Importer (Tlbimp.exe).

    This tool creates a .dll file. The name of the file can be determined using the TLBIMP command options.

  2. Move the resulting .dll file to the Macros BIN directory: ...\Microsoft Visual Studio 9\Common7\IDE\PublicAssemblies.

  3. Add a reference to the new component. In the Macros IDE, choose Add Reference on the Project menu to display the Add Reference dialog box. Alternatively, you can right-click the References node under the macro project node in Project Explorer and choose Add Reference.

  4. Select the newly-imported .dll in the list under the .NET tab.

The reference now appears in the macro's References node in Macro Explorer.

See Also

Concepts

Automating Repetitive Actions by Using Macros