Search code examples
excelribbonribbonxexcel-iribbonuivba

Excel Custom RibbonUI; Add Section Title for Menu


Im running 2016 Standalone Excel (32bit version). I've been building a custom ribbon and so far so good. The documentation is pretty fluid and well written. However, I cant find any way to include menu 'section titles' as seen below:

enter image description here

Specifically referencing section titles like in the picture (i.e., 'Cell size', 'Visibility' etc). I've seen other Add-Ins emulate this, unless they are COM Add-Ins. Here is the documentation I reference: https://msdn.microsoft.com/en-us/library/dd911038(v=office.12).aspx

Is it out of date? I've tried adding 'Menu with Title' to my project but that doesn't even work. I've also tried adding <labelControl /> , and the ribbon doesn't even load when the labelControl is within a Menu.

Additionally, my version of Excel won't even display a <dialogBoxLauncher> so I'm concerned some things just aren't compatabile with my Excel version to begin with. I'm following the documentation easily and everything else has worked just fine. I even have a editBox in the ribbon I use and don't run into any 91 errors with it. So I know it's not me.

Can anyone duplicate this with the provided API? My ribbon is structured with XML, so I've reduced as much error potential as possible, is that my problem? Should there be run-time code implemented specifically for section titles?


Short snippet of my setup

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad">

<ribbon>
<tabs>
<tab idMso="TabHome">        

<group id="GroupTextTools" insertAfterMso="GroupFont" label="Text Tools">
    <gallery  id="textcase_gallery" label="Case Select" columns="1" size="large" imageMso="WordArtInsertDialogClassic" onAction="TextCase_SwitchCase" >
        <item id="textcase_CapsButton" imageMso="TextAllCaps" label="Uppercase" screentip="Changes selected cells to all uppercase" />
        <item id="textcase_ProperButton" label="Propercase" imageMso="ChangeCaseDialogClassic" screentip="Changes selected cells to proper case" />
        <item id="textcase_LowerButton" label="Lowercase" imageMso="FontSizeDecrease" screentip="Changes selected cells to all small case" />
    </gallery>
</group>
</tab>

<tab id="CustomTab" label="*removed*" insertAfterMso= "TabDeveloper">

<!--
  GROUP A
-->
<group id="GroupFileOptions" label="File Options">

  <button id="fileoptions_CloseButton" label="Close &amp;&amp; Reopen" onAction="RunMacro" imageMso="SourceControlCheckIn" size="large" screentip="Saves Document, Closes &amp;&amp; Reopens immediately"/>

  <menu id="exportingmenu" label="Exporting" imageMso="FileCheckOut" size="large" screentip="Exporting Options">
      <menu id="exportmenu_AsRange" label="As Range"> <!-- This is where I would like section Titles to be instead of another menu -->
        <button id="exportmenu_range_CSVCButton" label="To CSV w/commas"/>
        <button id="exportmenu_range_CSVSButton" label="To CSV w/spaces"/>
        <button id="exportmenu_range_PDF" label="To PDF"/>
      </menu>
      <menu id="exportmenu_AsSheet" label="As Sheet"> <!--Goal is for this to be a section title, where I tried putting a <labelControl> -->
      </menu>
  </menu>

</group>

<!-- .... -->
</tab>
</tabs>
</ribbon>
</customUI>

Solution

  • After some trial and error, and an involuntary push from David Zemens by troubleshooting my errors, I've found that by cross referencing all the things I've tried with their Parent Elements, the only one that makes logical compiling sense is a <menuSeparator>, which just so happens to have a 'title' attribute. So by setting that you get a beautiful section title as shown:

    enter image description here

    <menuSeparator id="someID" title="Test title"/>