Use VBA to change the xml previously created by Custom UI Editor to customize the ribbon

evdokimos

Board Regular
Joined
Mar 10, 2003
Messages
72
Hi all
I have created a new ribbon using the Custom UI Editor. Part of the xml is shown below. I want to change it by VBA so that if a boolean variable in my project is True then the 'enable property' (last line below) changes from 'false' to 'true'. Any ideas?

<tabs>
<tab id="MyCustomTab" label="MyTab" >
<group id="customGroup1" label="MyGroup">
<button id="customButton1" label="Caption 1" size="normal" onAction="MyMacro" imageMso="DirectRepliesTo" enabled="false" />
</group>
</tab>
</tabs>
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
It doesn't work this way. You need to put a callback in the XML, getEnabled, that calls a procedure in VBA. The VBA procedure returns a boolean, and this is what controls whether the ribbon element is enabled.

Your code didn't come through, so I can't really work on it.

But essentially you replace enabled="true" in the XML with getEnabled="IsItEnabled". The VBA callback is

Code:
Public Sub IsItEnabled(control As IRibbonControl, ByRef returnedVal)
  ' control.Id is the name of the control
  ' use control.Id and the state of the VBA project to decide whether to enable the control
  ' the value of returnedVal is the enabled property:
  returnedValue = True ' or False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top