Microsoft Office Tutorials and References
In Depth Information
Table 11-4. IDTExtensibility2 Interface Methods
Called when the add-in is unloaded from the application.
Called when the application has completed the startup process.
The OnConnection method is called when an add-in is loaded into the application. The add-in
receives information about the environment it’s running in through a set of parameters. The
two key parameters are an object reference to the application object associated with the
application and information about how the add-in was started (that is, was the add-in started
from the COM Add-Ins dialog box or when the application was first started).
If the OnConnection method returns successfully, the add-in is considered by the application
to be loaded. If it returns an error message, the application destroys the object associated
with the add-in.
Tip Initializing the Add-In
You should use the OnConnection method to initialize the add-in and acquire any resources
needed by the add-in. Then these resources can be released in the OnDisconnection method.
The OnDisconnection method is called when the application wants the add-in to unload itself.
The application informs the add-in why the application is being unloaded (that is, the add-in
was unloaded via the COM Add-Ins dialog box or the application itself is shutting down).
The OnStartupComplete and OnBeginShutdown methods are called just before the applica­
tion is ready to accept user input and just after the user has requested the application to close.
Tip Making Changes to Excel
You should use the OnStartupComplete method to make any changes to the application,
such as adding new menu items or toolbar buttons. Then you can undo these changes in
the OnBeginShutdown method.
The OnAddInsUpdate method is called whenever the list of add-ins changes.
Warning You should be extremely careful about making changes to Excel when loading
an add-in because Excel has the ability to dynamically load an add-in while in cell edit mode.
Displaying a form or dialog box, changing the current selection, calling a property or method
in the Windows collection, or changing some Excel settings could cause Excel to fail.
Search JabSto ::

Custom Search