Question

I am trying to add a button to the ribbon using CommandBars, but I can't find any example or a way to do that.

I cannot use the CustomUI XML because I need to change the visibility of the button, and it is not supported by the CustomUI XML.

I have found a CommandBar called "Ribbon" with a CommandBarControl that is called "Ribbon" as well, but I don't see how I use it to place a button on "TabHome".

Does anyone know what am I missing here? or can point me out to an example?

Thanks!

Was it helpful?

Solution

As far as I know, you can't use CommandBars to control ribbon. And it makes no sense to do so, as CommandBars technology is depreciated for ribbon ui, and basically supported for compatibility only.

Did not quite get why you don't want to use ribbon xml to customize ribbon? It's the official way. To control button visibility, you should simply set a "getVisible" attribute of the button to your event handler (callback) and and in that callback return true/false to show/hide the button...

What you can't show/hide dynamically are built-in office buttons, but you should be able to show/hide your own buttons without any issues.

Looks quite similar to this one:

Is there a way to use VBA and XML to add a button to the Office 2010 Ribbon depending on a string in the file name?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top