Dela via


Office Primary Interop Assemblies

To use the features of a Microsoft Office application from a Visual Studio Tools for Office project, you must use the primary interop assembly for the application. The primary interop assembly enables managed code to interact with a Microsoft Office application's COM-based object model.

When you create a new Visual Studio Tools for Office project, Visual Studio adds references to the primary interop assemblies that are required to build the project. In some scenarios, you might need to add references to additional primary interop assemblies (for example, if you want to use a feature of Microsoft Office Word in a project for Microsoft Office Excel).

This topic describes the following aspects of using the Microsoft Office primary interop assemblies in Visual Studio Tools for Office projects:

  • Separate primary interop assemblies for building and running projects

  • Using features of multiple Microsoft Office applications in a single project

  • Primary interop assemblies for Microsoft Office 2003

  • Primary interop assemblies for the 2007 Microsoft Office system

For more information about primary interop assemblies, see Primary Interop Assemblies.

Separate Primary Interop Assemblies for Building and Running Projects

Visual Studio Tools for Office uses different sets of the primary interop assemblies on the development computer. These different sets of assemblies are in the following locations:

  • A folder in the program files directory.

    These copies of the assemblies are used when you write code and build projects. Visual Studio Tools for Office installs these assemblies automatically.

  • The global assembly cache.

    These copies of the assemblies are used when you run or debug projects. Visual Studio Tools for Office does not install and register these assemblies; you must do this yourself.

Primary Interop Assemblies in the Program Files Directory

When you install Visual Studio Tools for Office, the primary interop assemblies are automatically installed to a location in the file system, outside of the global assembly cache. When you create a new project, Visual Studio Tools for Office automatically adds references to these copies of the primary interop assemblies to your project. Visual Studio Tools for Office uses these copies of the primary interop assemblies, instead of the assemblies in the global assembly cache, to resolve type references when you develop and build your project. 

These copies of the primary interop assemblies help Visual Studio Tools for Office avoid several development issues that can occur when both the 2003 and the 2007 versions of the Office primary interop assemblies are registered in the global assembly cache.

Visual Studio Tools for Office installs these copies of the primary interop assemblies to the following locations on the development computer:

  • %ProgramFiles%\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11

  • %ProgramFiles%\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12

Primary Interop Assemblies in the Global Assembly Cache

To perform most development tasks, you must install and register the primary interop assemblies in the global assembly cache. To do this, perform a Complete installation of Microsoft Office, or install the redistributable package for the primary interop assemblies. For more information, see How to: Install Office Primary Interop Assemblies.

You must have the primary interop assemblies installed and registered in the global assembly cache to perform the following development tasks:

  • To create a document-level customization project.

  • To run or debug any Visual Studio Tools for Office project.

End user computers must also have the primary interop assemblies installed and registered in the global assembly cache to run Visual Studio Tools for Office solutions.

Using Features of Multiple Microsoft Office Applications in a Single Project

Every project template in Visual Studio Tools for Office is designed to work with a single Microsoft Office application. To use features in multiple Microsoft Office applications, or to use features in an application or component that does not have a project in Visual Studio Tools for Office, you must add a reference to the required primary interop assemblies. 

In most cases, you should add references to the primary interop assemblies that are installed by Visual Studio Tools for Office in the %ProgramFiles% directory. These versions of the assemblies appear on the .NET tab of the Add Reference dialog box. For more information, see How to: Target Office Applications Through Primary Interop Assemblies.

If you have installed and registered the primary interop assemblies in the global assembly cache, these versions of the assemblies appear on the COM tab of the Add Reference dialog box. You should avoid adding references to these versions of the assemblies, because there are some development issues that can occur when you use them. For example, if you have registered both the 2003 and the 2007 versions of the primary interop assemblies in the global assembly cache, your project will automatically bind to the version of the assembly that was registered last—even if you specify a different version of the assembly on the COM tab of the Add Reference dialog box.

Note

Some assemblies are added to a project automatically when an assembly that references them is added. For example, references to the Office.dll and Microsoft.Vbe.Interop.dll assemblies are added automatically when you add a reference to the Word, Excel, Outlook, Microsoft Forms, or Graph assemblies.

Primary Interop Assemblies for Microsoft Office 2003

The following table lists the primary interop assemblies that are available for Microsoft Office 2003.

Office application or component

Primary interop assembly name

Microsoft Access 11.0 Object Library

Microsoft.Office.Interop.Access.dll

Microsoft Excel 11.0 Object Library

Microsoft.Office.Interop.Excel.dll

Microsoft FrontPage 6.0 Web Object Reference Library

Microsoft.Office.Interop.Frontpage.dll

Microsoft FrontPage 6.0 Page Object Reference Library

Microsoft.Office.Interop.Frontpageeditor.dll

Microsoft Graph 11.0 Object Library (used by PowerPoint, Access, and Word for graphs)

Microsoft.Office.Interop.Graph.dll

Microsoft Outlook 11.0 Object Library

Microsoft.Office.Interop.Outlook.dll

Microsoft Outlook View Control (can be used in Web pages and applications to access your Inbox)

Microsoft.Office.Interop.OutlookViewCtl.dll

Microsoft Office Web Components 11.0 (spreadsheet, graph, and pivot table for Web pages)

Microsoft.Office.Interop.owc11.dll

Microsoft PowerPoint 11.0 Object Library

Microsoft.Office.Interop.PowerPoint.dll

Microsoft Project 11.0 Object Library

Microsoft.Office.Interop.MSProject.dll

Microsoft Publisher 11.0 Object Library

Microsoft.Office.Interop.Publisher.dll

Microsoft Smart Tags 2.0 Type Library

Microsoft.Office.Interop.SmartTag.dll

Microsoft Word 11.0 Object Library

Microsoft.Office.Interop.Word.dll

Microsoft Visual Basic for Applications Extensibility 5.3

Microsoft.Vbe.Interop.dll

Microsoft Forms 2.0 Object Library (programmable controls that can be used in applications)

Microsoft.Vbe.Interop.Forms.dll

Microsoft Office 11.0 Object Library (Office shared functionality)

office.dll

Primary Interop Assemblies for the 2007 Microsoft Office System

The following table lists the primary interop assemblies that are available for the 2007 Microsoft Office system.

Office application or component

Primary interop assembly name

Microsoft Access 12.0 Object Library

Microsoft.Office.Interop.Access.dll

Microsoft Office 2007 Access database engine Object Library

Microsoft.Office.Interop.Access.Dao.dll

Microsoft Excel 12.0 Object Library

Microsoft.Office.Interop.Excel.dll

Microsoft Graph 12.0 Object Library (used by PowerPoint, Access, and Word for graphs)

Microsoft.Office.Interop.Graph.dll

Microsoft InfoPath 2.0 Type Library

Microsoft.Office.Interop.InfoPath.dll

Microsoft InfoPath XML Interop Assembly

Microsoft.Office.Interop.InfoPath.Xml.dll

Microsoft Outlook 12.0 Object Library

Microsoft.Office.Interop.Outlook.dll

Microsoft Office Outlook View Control (can be used in Web pages and applications to access your Inbox)

Microsoft.Office.Interop.OutlookViewCtl.dll

Microsoft PowerPoint 12.0 Object Library

Microsoft.Office.Interop.PowerPoint.dll

Microsoft Project 12.0 Object Library

Microsoft.Office.Interop.MSProject.dll

Microsoft Publisher 12.0 Object Library

Microsoft.Office.Interop.Publisher.dll

Microsoft SharePointDesigner 12.0 Web Object Reference Library

Microsoft.Office.Interop.SharePointDesigner.dll

Microsoft SharePointDesigner 12.0 Page Object Reference Library

Microsoft.Office.Interop.SharePointDesignerPage.dll

Microsoft Smart Tags 2.0 Type Library

Microsoft.Office.Interop.SmartTag.dll

Microsoft Visio 12.0 Type Library

Microsoft.Office.Interop.Visio.dll

Microsoft Visio 12.0 Save As Web Type Library

Microsoft.Office.Interop.Visio.SaveAsWeb.dll

Microsoft Visio 12.0 Drawing Control Type Library

Microsoft.Office.Interop.VisOcx.dll

Microsoft Word 12.0 Object Library

Microsoft.Office.Interop.Word.dll

Microsoft Visual Basic for Applications Extensibility 5.3

Microsoft.Vbe.Interop.dll

Microsoft Office 12.0 Object Library (Office shared functionality)

office.dll

Binding Redirect Assembly for Microsoft Access Object Library

Policy.11.0.Microsoft.Office.Interop.Access.dll

Binding Redirect Assembly for Microsoft Excel Object Library

Policy.11.0.Microsoft.Office.Interop.Excel.dll

Binding Redirect Assembly for Microsoft Graph Object Library

Policy.11.0.Microsoft.Office.Interop.Graph.dll

Binding Redirect Assembly for Microsoft InfoPath Type Library

Policy.11.0.Microsoft.Office.Interop.InfoPath.dll

Binding Redirect Assembly for Microsoft InfoPath XML Interop Assembly

Policy.11.0.Microsoft.Office.Interop.InfoPath.Xml.dll

Binding Redirect Assembly for Microsoft Outlook Object Library

Policy.11.0.Microsoft.Office.Interop.Outlook.dll

Binding Redirect Assembly for Microsoft Outlook View Control

Policy.11.0.Microsoft.Office.Interop.OutlookViewCtl.dll

Binding Redirect Assembly for Microsoft PowerPoint Object Library

Policy.11.0.Microsoft.Office.Interop.PowerPoint.dll

Binding Redirect Assembly for Microsoft Project Object Library

Policy.11.0.Microsoft.Office.Interop.MSProject.dll

Binding Redirect Assembly for Microsoft Publisher Object Library

Policy.11.0.Microsoft.Office.Interop.Publisher.dll

Binding Redirect Assembly for Microsoft Smart Tags Type Library

Policy.11.0.Microsoft.Office.Interop.SmartTag.dll

Microsoft Visio Type Library

Policy.11.0.Microsoft.Office.Interop.Visio.dll

Binding Redirect Assembly for Microsoft Visio Save As Web Type Library

Policy.11.0.Microsoft.Office.Interop.Visio.SaveAsWeb.dll

Binding Redirect Assembly for Microsoft Visio Drawing Control Type Library

Policy.11.0.Microsoft.Office.Interop.VisOcx.dll

Binding Redirect Assembly for Microsoft Word Object Library

Policy.11.0.Microsoft.Office.Interop.Word.dll

Binding Redirect Assembly for Microsoft Visual Basic for Applications Extensibility 5.3

Policy.11.0.Microsoft.Vbe.Interop.dll

Binding Redirect Assembly for Microsoft Office Object Library

Policy.11.0.office.dll

Note

The binding redirect assemblies help make sure that the 2007 Microsoft Office version of the primary interop assemblies are loaded at run time. When a Visual Studio Tools for Office solution that references a Microsoft Office 2003 primary interop assembly runs on a computer that has the 2007 Microsoft Office version of the same primary interop assembly, the binding redirect assembly instructs the .NET Framework runtime to load the 2007 Microsoft Office version of the primary interop assembly. For more information, see Assembly Binding Redirection.

See Also

Tasks

How to: Target Office Applications Through Primary Interop Assemblies

Concepts

Excel Object Model Overview

InfoPath Solutions

Outlook Object Model Overview

PowerPoint Solutions

Project Solutions

Visio Object Model Overview

Word Object Model Overview

Other Resources

General Reference (Visual Studio Tools for Office)