Getting Started Programming Application-Level Add-ins
If you are just getting started creating application-level add-ins using Visual Studio Tools for Office, here is what you need to know.
Developing Add-in Projects
The experience of creating add-in projects is designed to be as close as possible to the experience of creating other class library projects. You can add references to other projects and to Web services by using the standard Visual Studio tools. You build and debug in a similar way; however, there are some differences.
For more information about debugging, see. For more information about how to create add-in projects, see .
The add-in projects that are available to you depend on which combination of Microsoft Visual Studio 2005 Tools for the Microsoft Office System (VSTO 2005) or Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System (VSTO 2005 SE) products you have installed. For more information, see.
Outlook 2003 Add-in Projects in VSTO 2005
VSTO 2005 includes a project template for Microsoft Office Outlook 2003 add-ins.
If you have installed VSTO 2005 SE, you should create new Outlook projects using the VSTO 2005 SE Outlook 2003 project template.
Write your code in the
ThisApplication class, which is provided in the ThisApplication.vb (in Visual Basic) or ThisApplication.cs (in C#) code file. There are two event handlers in the project template code. To run code when the add-in is loaded, add code to the
ThisApplication_Startup event handler. To run code just before the add-in is unloaded, add code to the
ThisApplication_Shutdown event handler.
For more information about this project template, see.
Accessing the Object Model of Outlook
To access the object model of Outlook 2003, use members of the
ThisApplication inherits from the Microsoft.Office.Tools.Outlook.Application class. This class wraps the Microsoft.Office.Interop.Outlook.Application class, which represents the Outlook application. This is the highest-level class in the Outlook object model. You can access the members of the Microsoft.Office.Interop.Outlook.Application class by using the keywords Me (in Visual Basic) or this (in C#) in the
ThisApplication class. Code that is outside the
ThisApplication class can access the
ThisApplication object by using
For code examples that demonstrate how to use the Outlook 2003 object model by using the
ThisApplication class, see . For more information about the object model of Outlook, see .
Add-in Projects in VSTO 2005 SE
VSTO 2005 SE includes project templates for many applications in Microsoft Office 2003 and the 2007 Microsoft Office system. For the complete list of applications, see.
Write your code in the
ThisAddIn class, which is provided in the ThisAddIn.vb (in Visual Basic) or ThisAddIn.cs (in C#) code file. There are two event handlers in the project template code. To run code when the add-in is loaded, add code to the
ThisAddIn_Startup event handler. To run code just before the add-in is unloaded, add code to the
ThisAddIn_Shutdown event handler.
For more information about the add-in project templates included with VSTO 2005 SE, seeand .
Accessing the Object Model of the Host Application
To access the object model of the host application, use the
Application field of the
ThisAddIn class. This field returns an object that represents the current instance of the host application. You can access this field by using
Me.Application (in Visual Basic) or
this.Application (in C#) in the
ThisAddIn class. Code that is outside the
ThisAddIn class can access this field by using
For more information about the object model of Microsoft Office applications, see.
A Setup project is included as part of all add-in project templates in Visual Studio Tools for Office. This project helps you deploy your solution to other computers. For more information, see.
Determining Which Outlook 2003 Add-in Project Template to Use
Use the VSTO 2005 SE version of the project template for any new Outlook 2003 add-ins that you develop. Future versions of Visual Studio Tools for Office will use the add-in programming model of the VSTO 2005 SE add-in project templates.
If you install VSTO 2005 SE with VSTO 2005, you can continue to work with existing Outlook 2003 add-in projects created by using VSTO 2005.
VSTO 2005 and VSTO 2005 SE both include project templates for Outlook 2003 add-ins. There is no functional difference between add-ins that are created by using either of these projects. However, the VSTO 2005 version of this project template provides the
ThisApplication class to write your code in, and the VSTO 2005 SE version provides the
ThisAddIn class. For more information, see and in this topic.
For more information about locating these project templates in the New Project dialog box, see.
For information about the architecture of add-ins created with Visual Studio Tools for Office, see.
For information about ways to customize the user interface (UI) of Microsoft Office applications by using add-ins, see.
For an introduction to automating Microsoft Office applications, see.