Export (0) Print
Expand All

How to: Target Office Applications Through Primary Interop Assemblies

When you create a new Visual Studio Tools for Office project in Visual Studio, a reference to the correct primary interop assembly (PIA) is added to your project automatically if the assembly is installed in your computer's global assembly cache (GAC). To automate the features of other Microsoft Office applications using managed code, you must add a reference to the appropriate component manually.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To add a reference to a primary interop assembly

  1. Open your Visual Studio Tools for Office project and select the project name in Solution Explorer.

  2. Open the Project menu and click Add Reference.

  3. Under the COM tab, select the component you want in the Component Name list. For a list of Microsoft Office primary interop assemblies and corresponding component names, see Office Primary Interop Assemblies.

  4. Click OK.

    The component name appears in the References folder of Solution Explorer.

If the primary interop assembly is not installed in the global assembly cache or is not accessible, Visual Studio generates an interop assembly for the project that might not work fully in all cases. When this happens, Visual Studio creates the assembly in the project folder instead of in the global assembly cache. You can find the location of the assembly by checking the Path property of the assembly in the Visual Studio Properties window. For more information, see "Assembly Cannot Be Initialized" in Troubleshooting in Office at Run Time.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft