The RibbonX
The code:
Option Explicit
Private oRibbon As IRibbonUI
Sub Onload(ribbon As IRibbonUI)
'Create a ribbon instance for use in this project
Set oRibbon = ribbon
lbl_Exit:
Exit Sub
End Sub
Sub myDDMacro(ByVal control As IRibbonControl, selectedID As String, _
selectedIndex As Integer)
MsgBox "What do you want to do with " & Choose(selectedIndex + 1, "Apples", "Bananas", "Kiwis", "Pears")
SaveSetting "Ribbon DD Demo", "Settings", "Index", CStr(selectedIndex)
lbl_Exit:
Exit Sub
End Sub
Sub GetSelectedItemIndex(ByVal control As IRibbonControl, ByRef Index)
'This procedure is used to select the last selected index.
Select Case control.ID
Case Is = "DD1"
Index = CLng(GetSetting("Ribbon DD Demo", "Settings", "Index"))
Case Else
End Select
lbl_Exit:
Exit Sub
End Sub
<?xml version="1.0"encoding="UTF-8"standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"onLoad="RibbonControl.Onload">
<ribbon>
<tabs>
<tab id="CustomTab1"label="My Tab">
<group id="CustGrp1"label="My Group" >
<dropDown id="DD1"label="My DD"getSelectedItemIndex="RibbonControl.GetSelectedItemIndex"
onAction="RibbonControl.MyDDMacro">
<item id="a"label="Apples"/>
<item id="b"label="Bananas"/>
<item id="k"label="Kiwis"/>
<item id="p"label="Pears"/>
</dropDown>
</group>
</tab>
</tabs>
</ribbon>
</customUI>