Target Office applications through primary interop assemblies

When you create a new 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 PIAs 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, such as Microsoft Office Access.

    Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects. See Features available by Office 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 Personalize the IDE.

To add a reference to a primary interop assembly

  1. Open your Office project and select the project name in Solution Explorer.

  2. On the Project menu, click Add Reference.

  3. On the Framework tab, select the PIA you want in the Component Name list. For more information about the available Microsoft Office primary interop assemblies, see Office primary interop assemblies.

    If the project targets the .NET Framework 4 or later, the Embed Interop Types property for the assembly reference is set to True by default. By using this setting, your solution does not require the PIA on end-user computers. For more information, see Design and create Office solutions.

    Note

    In Office projects, always add references to Office PIAs by using the .NET tab of the Add Reference dialog rather than the COM tab. For more information, see Office primary interop assemblies.

  4. Click OK.

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