How to: Target Office Applications Through Primary Interop Assemblies

When you create a new Visual Studio Tools for Office project, Visual Studio automatically adds references to the Microsoft Office primary interop assemblies (PIAs) that are required to build your project. You must add references to other primary interop assemblies in the following scenarios:

  • You want to use features of other Microsoft Office applications in your project. For example, you might want to use features of Microsoft Office Excel in a project for Microsoft Office Word.

  • You want to automate Microsoft Office applications that do not have dedicated projects in Visual Studio Tools for Office, such as Microsoft Office Access.

For more information about the Microsoft Office applications that are supported by Visual Studio Tools for Office, see Features Available by Application and Project Type.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. 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. On the Project menu, click Add Reference.

  3. On the .NET tab, select the primary interop assembly you want in the Component Name list. For more information about the available Microsoft Office primary interop assemblies, see Office Primary Interop Assemblies.

  4. Click OK.

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

See Also

Tasks

How to: Install Office Primary Interop Assemblies

Concepts

Managed Code and Office Programming with Visual Studio

Developing Office Solutions

Reference

Office Primary Interop Assemblies