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 Microsoft Office 2013 and Microsoft Office 2010. For more information, 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 Visual Studio Settings.
To add a reference to a primary interop assembly
Open your Office project and select the project name in Solution Explorer.
On the Project menu, click Add Reference.
On the .NET 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
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.
Click OK.
The assembly name appears in the References folder of Solution Explorer.
See Also
Tasks
How to: Install Office Primary Interop Assemblies
Reference
Office Primary Interop Assemblies
Concepts
Writing Code in Office Solutions