Export (0) Print
Expand All

Managed Code and Office Programming with Visual Studio

The key technology that makes creating an integrated Microsoft Office solution possible is Automation, which is part of the Component Object Model (COM) technology. Automation enables you to use code to create and control software objects exposed by any application, DLL, or ActiveX control that supports the appropriate programmatic interfaces.

Automation Using Managed Code

Microsoft Office applications expose much of their functionality to Automation. However, you cannot use managed code (such as Visual Basic or C#) directly to automate COM-based technology such as Microsoft Office applications. To work with unmanaged COM objects using managed code in Visual Studio, you must use an interop assembly. For more information, see How to: Target Office Applications Through Primary Interop Assemblies.

Microsoft Visual Studio 2005 Tools for the Microsoft Office System (VSTO 2005) additionally exposes host controls that extend existing Microsoft Office Word 2003 and Microsoft Office Excel 2003 objects. The host controls add data binding and programmable events to objects such as bookmarks and named ranges. For more information about host controls, see Word Host Controls and Excel Host Controls.

Visual Studio can help you incorporate Microsoft Office applications into your custom solutions by providing projects and classes to make Automation easier for some Microsoft Office applications. You can also use Visual Studio as your development environment for other Microsoft Office applications that do not have dedicated projects in Visual Studio Tools for Office.

Visual Studio Tools for Office includes templates for two types of projects: document-level customizations and application-level add-ins. For more information, see Office Solutions Development Overview.

Document-Level Projects

VSTO 2005 includes document-level project templates for Word 2003 and Excel 2003. These project templates contain references to required assemblies and also contain useful classes and methods. For more information, see Office Project Templates.

Document-level projects are extensible, similar to other kinds of Visual Studio projects. For example, you can add references to any other managed code assembly to your solution; however, you cannot reference another Visual Studio Tools for Office project assembly. For more information, see Assemblies in Office Projects Overview.

Application-Level Projects

VSTO 2005 includes an Outlook 2003 add-in project template, and Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System (VSTO 2005 SE) includes add-in project templates for many more applications in Microsoft Office 2003 and the 2007 Microsoft Office system. These project templates contain references to required assemblies and they also contain useful classes and methods. For more information, see Outlook Add-in Project Template, 2003 Microsoft Office Add-in Project Templates, and 2007 Microsoft Office Add-in Project Templates.

For more information about the differences between VSTO 2005 and VSTO 2005 SE, see Features Available by Product Combination.

Other Office Applications

If you want to use managed code to automate other Microsoft Office applications, such as Microsoft Office Access, you can still use Visual Studio as your development environment. However, there are no project templates for these other applications; instead, you must perform additional steps in your existing projects to be able to call unmanaged code using Visual Basic or C#. For more information, see How to: Automate Office Applications By Using Primary Interop Assemblies.

For more information about using managed code to develop solutions using Office applications, see the following technical articles:

See Also

Community Additions

ADD
Show:
© 2014 Microsoft