Figure

References set to the Access and DAO object libraries in the VB References dialog.

References - COM Add-In.vbp

Available References:

0 Visual Basic For Applications a @ Visual Basic runtime objects and procedures IE! Visual Basic objects and procedures 0 OLE Automation 0 Microsoft Add-In Designer M Microsoft Office 12.0 Object Library v Microsoft" Access'2007 '(Betaí'ÓbWctUbrary j

0 Microsoft DAO 3.6 Object Library

□ IA5 Helper COM Component 1.0 Type Library

□ IAS RADIUS Protocol 1.0 Type Library

□ Active Directory Types

□ Active Setup Control Library

□ ActiveMovie control type library r i

1 I ArMvfiX DI I h~i nprfnrm Minmhnn nf MS Rñnnsitnrv V ' < >

[-Microsoft Accesstf^ry-

You can now modify the form (if you need a form in your add-in), and the code in the standard module and designer, to create a custom COM add-in for use in Access:

1. First open the designer and fill in the basic information about the add-in on its General tab (the Advanced tab rarely needs to be modified from its default settings).

2. Enter the add-in's display name and description in the "Addin Display Name" and "Addin Description" boxes, then select the Office application (Access in this case) from the Application drop-down list (see Figure 13.6). The currently running Office version is automatically selected in the Application Version box.

3. Finally, select the add-in's load behavior from the "Initial Load Behavior" drop-down — Startup is the appropriate choice if you want the add-in to always be available in any Access database (which is the usual case).

The SharedCode module (as its name suggests) contains code that applies to the entire add-in, such as an error handler and the standard code that creates and removes the add-in's toolbar buttons or menu items (for the rare case where a multi-application COM add-in puts a command on the same menu or toolbar in each Office application).

The code in the Designer (which I named AccessDesigner to indicate that it is an Access Designer) contains code specific to Access. (If you are creating a multi-application add-in, you need to create one Designer for each Office application that your add-in supports). Some of the standard code in the Designer works with the frmCOMAddIn form; if your add-in doesn't need to display a form, you can delete or comment out any code that references this form, but it is a good idea to leave all the procedures in the module, in case you might need them later on.

Figure 13.6

Entering the COM add-in's identifying information and other options in the Designer dialog.

Figure 13.6

The Designer code includes the procedures that implement the add-in's functionality; they require little (if any) modification from those that would run in an Access add-in.

0 0

Post a comment