Access.2007.VBA.Bibl..

(John Hannent) #1
The next step is to add some Importsstatements under the two default statements in the
Declarations section of the class module, using IntelliSense (see Figure 16.17):

Imports Extensibility
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Core
Imports Access = Microsoft.Office.Interop.Access

FIGURE 16.17

Using IntelliSense to add an Imports statement to the Connect class module.


Next, replace the class-level variables (applicationObjectand addInInstance), both
declared as Object, with typed references, replacing Dimwith Private(I also gave the
applicationObjectvariable a more application-specific name, appAccess):

Private appAccess As Microsoft.Office.Interop.Access.Application
Private addInInstance As Microsoft.Office.Core.COMAddIn

After adding statements and modifying the variables, there are some more modifications to be
made to the code in the Connect class module. These changes are described in the next section.

Modifying the Connect Class Module Code ............................................................


If you were (for example) creating an Excel 2007 add-in using VSTO 2005 with the 2007 upgrade,
you could add Ribbon support to your add-in by simply adding a Ribbon Support item to your
project. Visual Studio 2005 lacks a Ribbon Support item, and VSTO doesn’t support creating
Access add-ins, so this step requires extensive manual modification of the Connect class module,
to support working with Access and the Ribbon.

Customizing the Access Ribbon with a Visual Studio 2005 Shared Add-in 16

Free download pdf