Page 278 - Microsoft Office Excel 2003 Programming Inside Out
P. 278

Microsoft Office Excel 2003 Programming Inside Out

                             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:
                               1@ Start Visual Basic 6. Then choose the AddIn project template in the New Project dialog
                                  box by selecting AddIn and pressing the Open button.




























                               2@ 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.
                               3@ 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.)
             Chapter 11
                               4@ 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.









                252
             Part 4:  Advanced VBA
   273   274   275   276   277   278   279   280   281   282   283