Microsoft Office Tutorials and References
In Depth Information
Creating a User Interface for Your Add-In
The following event code, found in the ThisWorkbook module of the add-in file, establishes the
custom user interface:
Private Sub Workbook_Open()
‘Declare a CBC variable for the custom menu item.
Dim objCmdControl As CommandBarControl
‘The custom menu item will be named “Sheet Manager”
‘and it will go onto the Tools menu for versions before 2007.
Set objCmdControl = _
Application.CommandBars(“Worksheet Menu Bar”) _
‘For the new menu item, give it a meaningful caption,
‘help it to clearly stand out by starting a BeginGroup.
‘The OnAction method will call the UserForm.
‘The Face ID is a small icon next to the menu item
‘that is optional, but adds a feeling of customization.
.Caption = “Sheet Manager”
.BeginGroup = True
.OnAction = “SheetManager”
.FaceId = 144