Add Drop Button menu to the Ribbon Control

Drop Button is an important part of all modern interfaces. In xlCompiler you need a few lines of VBA code to create such element.
Drop Ribbon Button
' add button
With .AddDropButton
' initialize it
.Image = "Dollar.32"
.Caption = "Currency: USD"
.Name = BTN_CURRENCY
.OnAction = "OnApplyCurrency"
' create and initialize Drop Menu
With .Menu
' add 3 commands to the menu
With .AddCommand
.Caption = "USD"
.Tag = "Currency.USD"
.Image = "Dollar"
.OnAction = "OnSelectCurrency"
End With
With .AddCommand
.Caption = "EUR"
.Tag = BTN_EURO
.Image = "Euro"
.OnAction = "OnSelectCurrency"
End With
.AddSeparator
With .AddPopup
.Caption = "Currency Settings ..."
.Image = "Options"
With .AddCommand
.Caption = "Enable\Disable EURO"
.Image = "Pencil"
.Tag = BTN_ENABLE_EURO
.OnAction = "OnEnableEuroCurrency"
End With
End With
End With
End With
As you can see every command needs 6 lines of VBA code.
When you click on the button subroutine defined by Button::OnAction property is called.
But when you select any of the commands in the drop down menu - Command::OnAction property is used to call the routine.
In the example above we are using 2 different routines to apply selected currency and to select currency.
Go to top