O'Reilly logo

Programming Excel with VBA and .NET by Steve Saunders, Jeff Webb

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Visual Add-ins

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

The Workbook_Open and 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_AddinInstall and Workbook_AddinUninstall events occur only when the user selects or deselects the add-in from the Add-Ins dialog (Figure 22-3).

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required