Microsoft Office 2000/Visual Basic Programmer's Guide |
Before you can use a COM add-in in an Office 2000 application, the add-in DLL must be registered, like any other DLL on the computer. The DLL's class ID is registered beneath the \HKEY_CLASSES_ROOT subtree in the registry. The DLL can be registered on a user's computer by using a setup program like the ones created by the Visual Basic 6.0 Package and Deployment Wizard, or by running the Regsvr32.exe command-line utility that's included with Windows. Adding a COM add-in by using the COM Add-ins dialog box also registers the DLL if it was created with Visual Basic 6.0.
Registering the DLL beneath the \HKEY_CLASSES_ROOT subtree informs the operating system of its presence, but additional information must be added to the registry in order for the add-in to be available to an Office 2000 application. This is the information that you can specify in the add-in designer — the add-in's name, description, target application, target application version, and initial load behavior. The add-in designer ensures that this application-specific information is written to the correct place in the registry at the same time that the add-in DLL is registered. The COM Add-ins dialog box displays the information contained in the subkey for the corresponding Office 2000 application.
Since Visual Basic 5.0 does not support the add-in designer, if you're developing in Visual Basic 5.0, you have to add the additional information to the registry yourself on each computer where the add-in is installed.
This subkey must be added to the following registry subkey, where appname is the name of the application in which the add-in will run:
\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\appname\AddIns
The new subkey itself must be the programmatic identifier of the COM add-in, which consists of the name of the project followed by the name of the class module or add-in designer. For example, the registry subkey for the Image Gallery add-in for Word would be ImageGallery.dsrImageWord.
The following table describes the entries that you can add beneath this subkey. Only the LoadBehavior entry is required; the others are optional.
Name | Type | Value |
Description | String | Name to appear in COM Add-ins dialog box |
FriendlyName | String | String returned by Description property |
LoadBehavior | DWORD | Integer indicating load behavior: 0 (None), 3 (Startup), 9 (Load on Demand), or 16 (Load At Next Startup Only) |
For more information about registering an add-in created in Visual Basic 5.0, see "Distributing COM Add-ins Created with Visual Basic 5.0" later in this chapter.