The above thread advises to have a hashtable of the items upfront, cache the selected id in the onAction() of the dropdown and use that selected id to find the item from the hashtable in the onAction() of the button.

BUT, in my case, I populate the ribbon XML from the database. This ribbon XML obviously has the XML for dropdown and I am useing macros to interact with the dropdown and other controls in the ribbon. I am not sure how to have a collection upfront which can be used by the macro similar to approach described in the above thread.

@belisarious, I populate the ribbonXML from the database and then add that ribbonXML as a part to the word document using C#. I can not create the macros dynamically in the word file so I am copying from another docm file. Even If I construct a hashtable in C# code, How can I pass the same to the macro so that It could make use of the same? Does this make sense? Is there a better way?
–
Ashish GuptaDec 30 '10 at 12:58

Soooo.... why can't you use the onAction callback to retrieve/store the selected item? (Also suggested in that thread you linked to.)
–
NickJan 3 '11 at 5:38

Note the callbacks for getItemLabel and onAction. Interestingly, getItemLabel is meant for setting the item on the dropdown (get by the dropdown). It is kinda confusing but thats the way it is and thats why I named my method as "SetTheSelectedItemInDropDown".

Function "GetTheSelectedItemInDropDown" for the onAction is to get the selected item.

Now following is the macro code:-

' Declare a global variable to hold the selected item
Dim itemName As String
' Definition of GetTheSelectedItemInDropDown which gets the selected item of the dropdown
Sub GetTheSelectedItemInDropDown(control As IRibbonControl
, id As String, index As Integer)
If control.id = "ddlItems" Then
itemName= id
End If
End Sub
'Definition for SetTheSelectedItemInDropDown which sets the value in the dropdown from the global variable
Sub SetTheSelectedItemInDropDown(control As IRibbonControl,
index As Integer, ByRef returnedVal)
If control.id = "ddlItems" Then
returnedVal = itemName
End If
End Sub