changing ribbon button text on click event

Apr 2, 2012 at 5:52 AM


I need to change the text of a ribbon button on the click event.

Can that be achieved.


for e.g. there is a button with text "ON"  clicking it should change its text to  "OFF"





Apr 2, 2012 at 2:57 PM

Hi Prasad,

To do this you'll use the callback version of the button text - probably getText - and implement a callback in your ExcelRibbon class that returns the current text. Then from the button handler you invalidate the control, to ensure that it updates.

If it is only for one button, it's not too bad, but if you will have many dynamic aspects to your ribbon you should probably make some helper classes to simplify the implementation.

I think the details you need should be in the discussions and links here: and here:



Apr 3, 2012 at 5:25 AM

Hi Govert,

Thanks. I managed to get the things worked.

Added the getlabel attribute to the ui xml for the button and added the callback GetLabel which changes the text of the button at runtime.