ffice is a staple in most corporations, and .NET developers can easily take advantage of its power and omnipresence. The Visual Studio Tools for Office provide the ability to use .NET code with Office 2003 applications. With it, you can create code using Microsoft Visual Basic .NET (VB.NET) or C# (or other .NET languages) and integrate that code into your own Office 2003 tools.
|Examining the Code|
Once the wizard has run, you can examine the project it created. The first item to examine is the references added by the wizard. The wizard creates a project with all the standard .NET references (System, System.Data, System.XML, etc.) and it also adds references to Microsoft.Office.Core, Microsoft.Office.Interop.Word and Microsoft.VBE.Interop.Forms. These references are assemblies used to communicate with Office 2003 and are installed when you perform a complete installation of Office 2003. If you haven’t installed them from your Office 2003 CDs, the Visual Studio Tools for Office will do that for you.
The next item to examine is the class created by the wizard. The class created by the wizard is partially defined in Table 1.
Table 1: Definition of the class created by the Visual Studio Tools for Office Wizard.
Other items to note are the properties ThisDocument and ThisApplication (ThisDocument is known as ThisWorkbook in Excel 2003 projects). These variables are references to the current document and application. These two variables are cast as their proper Office data types in the _Startup() subroutine created by the wizard.