I have a combobox in a custom Ribbon created with CustomEditor (XML).
I would like to modify combobox elements when I press a command button located in a Excel Sheet.
<comboBox id="Combo3" getItemCount="Módulo4.Número_Elementos_Combobox" getItemID="Módulo4.Identificador_Items" getItemLabel="Módulo4.Texto_Items" image="Foto_Excel" onChange="Módulo1.Todos_Los_Combos">
</comboBox>
Many thanks in advance. Regards. José.
You'll need to use the InvalidateControl method of the Ribbon object in order to invalidate the cache, and update the combobox.
First, if you haven't already done so, you'll need to include an onLoad paramater for your customUI tag in your RibbonX code. This paramater will specify the VBA callback procedure to be executed when the workbook is opened, so that the ribbon object can be created.
Then, you'll need to include the VBA callback procedures for getItemCount, getItemLabel, and getItemID. When the combobox is invalidated, getItemCount gets called. Then, in turn, getItemLabel and getItemID get called.
The getItemCount procedure is where you specify how many items you want to include in your combobox. As a result, both getItemLabel and getItemID each get called the same number of times so that the ID's and labels can be updated accordingly.
Then, of course, you'll need include the procedure that will be assigned to your button, which will actually invalidate the combobox.
Since you haven't provided all of the relevant details, here's an example that hopefully you'll be able to adapt for your needs.
RibbonX Code
VBA Code