Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: 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 application-level projects for Office 2013 and Office 2010. See Features Available by Office Application and Project Type.

NoteNote

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 Customizing Development Settings.

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 the .NET Framework 4.5, 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 Designing and Creating Office Solutions.

    Note 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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.