I'm trying to add a dynamic dropdown to customised ribbon for an xlsm file. The idea of the dropdown is, it will generate a list from existing excel range. If user click any item of the dropdown list, it should take the user to the same named worksheet. It can generate the dropdown list correctly but when I try to click it, it says "Wrong number of arguments or invalid property assignment"
There are other customisde ribbon buttons on that tab and they works fine, so I think the problem may generates from xml
code part or the onAction
subprocess part. I'm also glad to provide other code segments in necessary.
Xml
<!-- Dynamic dropDown Group -->
<group id="tool5" label="Sheet DropDown" autoScale="true">
<dropDown id="DropDown1" label= "Sheet Name" sizeString="WWWWWWWWWWWWW" supertip="Please select a sheet, add more sheetsname in Lookup sheet" imageMso="InsertExcelSpreadsheetMenu"
getItemCount="GetDropdownItemCount" getItemLabel="DropdownItemLabel" onAction="SubdropDownAction" />
</group>
VBA
I think GetDropdownItemCount
and DropdownItemLabel
is working fine since the dropdown list is properly generated.
Public Sub SubdropDownAction(control As IRibbonControl, index As Integer)
Dim SelectedSheet As String
Select Case control.ID
Case "DropDown1"
SelectedSheet = Range("Range_DropdownsheetName").Cells(index + 1).Value
ThisWorkbook.Sheets(SelectedSheet).Activate
Case Else
End Select
End Sub