Excel2010 Doesn't support CommandBars?

Mar 22, 2012 at 9:48 AM

I use ExcelDna for excel 2010. The <CommandBars> defined in dna file is useless. I looked into the ExcelCommandBars.cs, and found the following

internal static void LoadCommandBars(XmlNode xmlCustomUI, GetImageDelegate getImage)
if (xmlCustomUI.NamespaceURI != "http://schemas.excel-dna.net/office/2003/01/commandbars")
// Unsupported version ....
// TODO: Log display ....?
Debug.Print("Unsupported commandBars version.");

It seems CommandBars is not supported for versions after 2003. Is this true? And what's the design consideration for that?

Mar 22, 2012 at 10:09 AM

Hi there,

Excel-DNA is designed to give you full access to the different interface customisation options on all Excel versions. But in particular I wanted to make it possible to make a single add-in that contains both the ribbon customisations for Excel 2007/2010 and a CommandBars fallback for older Excel.

Excel 2007/2010 uses the new ribbon interface. The ribbon interface can be configured with the xml strings and a class that handles the events - there is no simple object model like the older CommandBars. Excel does not support using the CommandBars COM interfaces to customise the ribbon. For backward compatibility with older versions of Excel, Excel 2007/2010, the older CommandBars are supported by Excel, but all custom CommandBars are placed under an Add-Ins tab on the ribbon. So if you use the CommandBars API to add menus, you're adding them into that Add-In tab.

Excel-DNA gives you a few different options for doing the CommandBars support:

1. Add it using an Excel-DNA specific .xml format in the .dna file that somewhat mirrors the ribbon xml (why do you say "The <CommandBars> defined in dna file is useless."?)

2. Add it programmatically in your add-in code, from a string that contains the xml info,

3. Add it programmatically in your add-in code, calling the COM CommandBar interfaces, which is compatible with CommandBars customisation you'd have done in VBA.

The main limitation of the Excel-DNA xml string format is that you can't define ComboBox callbacks, but the rest should work fine. Under Excel 2007/2010 all of these will only affect the Add-In tab of the ribbon.

The code snippet you see is just a way to allow future versioning of that CommandBars xml string. The namespace just defines an xml schema, and has nothing to do with the Excel versions supported.

What would you like to do?


Mar 23, 2012 at 10:52 AM

Hi Govert,

Thanks for your incredible speedy response. I choose the 2nd option to define the context menu bar. I also find the work around discussed in http://exceldna.codeplex.com/discussions/281069.

The reason that I think "The <CommandBars> defined in dna file is useless." is because I define a class derived from ExcelRibbon.

Thanks again for your awesome work.