This documentation is archived and is not being maintained.

How to: Automate Office Applications By Using Primary Interop Assemblies

Visual Studio 2005

Different versions of Visual Studio Tools for Office provide projects for different sets of Microsoft Office applications. If you want to use managed code to automate Office applications that are not supported by your installation of Visual Studio Tools for Office, you can still use Visual Studio as your development environment. However, you must perform additional steps in your existing projects to be able to call unmanaged code using Visual Basic or C#.

For more information about the Microsoft Office applications that are supported by different versions of Visual Studio Tools for Office, see Features Available by Product Combination. For more information about using Visual Studio to develop Microsoft Office solutions, see Managed Code and Office Programming with Visual Studio.

To automate an Office application by using the primary interop assembly

  1. Add a primary interop assembly to your global assembly cache (GAC) for each Office application that you want to automate. For more information, see How to: Install Office Primary Interop Assemblies.

  2. Add a reference in your project to the primary interop assembly. For more information, see How to: Target Office Applications Through Primary Interop Assemblies.

When there is a reference to a primary interop assembly in your project, you can write managed code that automates the corresponding Microsoft Office application. For more information about using managed code to develop with Microsoft Office applications, see Interoperating with Unmanaged Code, the technical article "Microsoft Office Development with Visual Studio" (, and the Knowledge Base article "INFO: Develop Microsoft Office Solutions with Visual Studio .NET" (;en-us;q311452).

See Also