Visual add-ins interact with the active sheet, selected range, or active workbook through menu items, dialog boxes, and toolbars that you create from within the add-in. By convention, visual add-ins add a menu item to the Tool menu in Excel (see Table 22-1).
Add-ins provide the following events that let you add and remove menu items and toolbars when the add-in is installed or uninstalled:
' ThisWorkbook class Private Sub Workbook_AddinInstall( ) ' Add menu items and toolbars here. End Sub Private Sub Workbook_AddinUninstall( ) ' Remove menu items and toolbars. End Sub
Workbook_BeforeClose events aren’t as useful from add-ins as the preceding events because they occur too often—whenever Excel opens or closes. The
Workbook_AddinUninstall events occur only when the user selects or deselects the add-in from the Add-Ins dialog (Figure 22-3).