I have a custom Excel Ribbon containing a dropdown that allows the user to switch worksheets. This works fine, however, it only works one way. For example, one scenario is the user selects a sheet name in the dropdown and the sheet changes to that one. But if they change the sheet tab, the dropdown does not update. What I need is the dropdown to always display the active sheet, no matter how the user changes it.
How can I do this?
XML
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="tab1" label="Custom Tab" insertAfterMso="TabHome">
<!--Dropdown-->
<group id="Group5" label="Dropdowns">
<dropDown id="dropDown1" label="Dropdown Box" onAction="DDonAction">
<item id="item1" label="Sheet1" imageMso = "HappyFace" />
<item id="item2" label="Sheet2" imageMso = "FontColorMoreColorsDialog" />
<item id="item3" label="Sheet3" imageMso = "NewDistributionList" />
</dropDown>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
VBA
'Dropdowns
Sub DDonAction(control As IRibbonControl, id As String, Index As Integer)
Select Case Index
Case 0
ActiveWorkbook.Sheets("Sheet1").Activate
Case 1
ActiveWorkbook.Sheets("Sheet2").Activate
Case 2
ActiveWorkbook.Sheets("Sheet3").Activate
End Select
End Sub