|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
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.
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.
To add a reference to a primary interop assembly
Open your Visual Studio Tools for Office project and select the project name in Solution Explorer.
Open the Project menu and click Add Reference.
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.
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.