Microsoft Office Tutorials and References
In Depth Information
Registry Keys
COM add-ins are required to provide certain entries in the Windows registry. All registry
entries are stored using the following key, where App is the name of the Office application
(such as Excel) and ProgID is the ProgID value associated with the add-in. Typically, these
entries are made by the add-in’s installation program.
Warning Manually changing the Windows registry can be dangerous. If you don’t have a
lot of experience editing the Windows registry, you should look but don’t touch, and rely on
the setup program for the add-in to make the proper changes. Should you wish to view
and/or change registry entries, you can use the RegEdit program. (Click the Start button,
click Run, type RegEdit, and click OK.)
Underneath the key specified above are a series of subkeys that contain specific information
about the add-in. The LoadBehavior subkey is a DWORD value that determines when an
addin is loaded by the Office application. A value of 0 means that the add-in is not loaded. A
value of 3 means that the add-in should be loaded when the application starts. A value of 9
means that the add-in is loaded when requested by the user. A value of 16 means that the
add-in is loaded once, the next time the application starts.
The Description subkey is a String value that’s displayed in the COM Add-Ins dialog box,
whereas the FriendlyName subkey is a String value that’s returned by the add-in’s Description
Add-ins that use the IDTExtensibility2 interface also should have a registry entry named
CommandLineSafe . This is a DWORD value that marks an add-in as safe to use in applica­
tions that don’t support a user interface. A value of 0x00 means that the add-in needs a user
interface, whereas a value of 0x01 means that the add-in doesn’t rely on a user interface.
Building an Automation Add-In with Visual Basic 6
Visual Basic 6 includes a template that simplifies creating add-ins that use the
IDTExtensibility2 interface, which you can use to create an automation add-in that
implements the same DiscountPrice function that was built for the Excel add-in.
Designing the Add-In
The code for the automation add-in is shown on the next page. The module begins by defin­
ing a public variable that will hold the reference to the Excel.Application object. The rest of
the code implements the five methods required to handle the IDTExtensibility2 interface,
along with one additional function that implements the same DiscountPrice function that
was used in the Excel add-in earlier in this chapter.
Search JabSto ::

Custom Search