|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
How to: Automate Office Applications By Using Primary Interop Assemblies
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. For more information about using Visual Studio to develop Microsoft Office solutions, see .
To automate an Office application by using the primary interop assembly
Add a primary interop assembly to your global assembly cache (GAC) for each Office application that you want to automate. For more information, see.
Add a reference in your project to the primary interop assembly. For more information, see.
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 http://msdn2.microsoft.com/en-us/library/aa188489(office.10).aspx), and the Knowledge Base article "INFO: Develop Microsoft Office Solutions with Visual Studio .NET" (http://support.microsoft.com/default.aspx?scid=kb;en-us;q311452)., the technical article "Microsoft Office Development with Visual Studio" (