Microsoft Office Tutorials and References
In Depth Information
EXE or DLL?
COM add-ins can be created as either a DLL or an EXE file. Both have their advantages and
disadvantages. Generally, a DLL component will perform better than an EXE component
because the DLL is run in-process, which avoids the extra overhead associated with calling
an out-of-process component.
However, a DLL component can’t include a main program, which can be a serious limitation
if you have a utility that you want to access either as a stand-alone program or as an Office
add-in. An EXE component also has the advantage of isolating the add-in’s execution from
that of the host application.
So, unless you really need either the isolation or main program feature of an EXE component,
you should develop your add-in as a DLL component.
Another difference between a COM add-in and an automation add-in is that COM add-ins
must support the IDTExtensibility2 interface, whereas automation add-ins might or might
not use this interface.
Tip Displaying the COM Add-ins dialog box
Accessing the COM Add-ins dialog box can be tricky because the only way to access this
dialog box is by adding the COM Add-Ins button to the toolbar. Right-click a toolbar, and
choose the Customize command (lists at the bottom of the context menu). Click the
Commands tab. Select Tools in the Category list, and then drag COM Add-Ins from the
Commands list to a toolbar. Then click the COM Add-Ins button to display the COM Add-Ins
dialog box.
Using the IDTExtensibility2 Interface
The IDTExtensibility2 interface is a general interface that’s shared by many products besides
Microsoft Office. This interface represents a standard way for an application to communicate
with an add-in. Any COM add-in must implement each of the methods listed in Table 11-4.
Table 11-4. IDTExtensibility2 Interface Methods
Method
Description
OnAddInsUpdate
Called when a change occurs to the list of add-ins, such as an
add-in being loaded or unloaded.
OnBeginShutdown
Called when the application is being shut down. Remember that
this method will be called only if the add-in is loaded.
OnConnection
Called when the add-in is loaded into the application. This can
occur when the add-in is loaded through the Add-Ins dialog box or if
the add-in is automatically loaded when the application starts.
Search JabSto ::




Custom Search