Microsoft Office Tutorials and References
In Depth Information
Of the five methods associated with the IDTExtensibility2 interface, only two do any work in
this example. The AddinInstance_OnConnection method saves an object reference to the
Excel application that was passed using the Application parameter. This object is necessary
for the add-in to access the information stored in the Excel application.
The AddinInstance_OnDisconnection method releases the object reference to the Excel object.
Besides being a good programming practice, releasing the object helps to ensure the stability
of the add-in.
To create a new add-in in Visual Basic 6, follow these steps:
Start Visual Basic 6. Then choose the AddIn project template in the New Project dialog
box by selecting AddIn and pressing the Open button.
When Visual Basic 6 starts, go to the Project Explorer window. Right-click frmAddIn,
and choose Remove frmAddIn from the popup menu because this form won’t be
needed in this project.
Choose Project, MyAddIn Properties from the main menu to display the Properties
dialog box. Change MyAddIn in the Project Name field to something more meaningful.
(See Figure 11-6.)
Next double-click the Connect item under the Designers icon in the Project Explorer.
This will open the AddInDesigner. Go to the Properties window, and change the Name
property from Connect to a more appropriate description.