Double ribbon items for SplitButton - ms-office

I develop MS Office add-in which extends ribbon in the following way:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" loadImage="GetImage" onLoad="OnRibbonLoad">
<ribbon>
<tabs>
<tab idMso="TabHome">
<group id="MyAppGroup" label="MyApp">
<splitButton id="SaveSplitButton" size="large" getEnabled="GetSaveButtonEnabled">
<menu id="SaveMenu" label="Save" itemSize="normal">
<button id="SaveMenuButton" image="save.png" label="Save to MyApp" onAction="SaveCommand" screentip="Saves the document" />
<button id="SaveAsMenuButton" label="Save to MyApp As" onAction="SaveAsCommand" screentip="Saves the document under a new name" getEnabled="GetSaveAsButtonEnabled"/>
</menu>
</splitButton>
</group>
</tab>
</tabs>
When I go to File > Options > Customize Ribbon (in any Office application) I expect to see "MyApp" group in "Home" tab with one "Save" menu having only one "Save to MyApp" and one "Save to MyApp As" subitems in it. But instead I get "Save to MyApp" item doubled under the "Save" menu.
I know that if I move "SaveMenuButton" from menu right into the splitButton then I'll get rid of that doubling but I need these two options in the menu.
Experts! Please help!

Related

insertAfterMso="GroupAlignmentExcel" in xml file doesn't work

I'm trying to add a button to excel's ribbon Home tab. It seems like this section from the xml file:
insertAfterMso="GroupAlignmentExcel"
doesn't work, because the group end up at the end on the tab.
Full xml code:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab idMso="TabHome" >
<group id="CenterAll" label=" ">
<button id="CenterAllButton" label="Center All" onAction="CenterAll" imageMso="TableCellAlignMiddleCenter" size="large" insertAfterMso="GroupAlignmentExcel" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Does anyone know what could be my problem?
Does this code works for you?

Custom ribbon tab disappears in second launch

I created a basic custom Excel ribbon tab with 5 buttons. When I edit the custom ribbon (using Office RibbonX Editor) everything works fine when I launch the Excel file for the first time after the ribbon edit.
But the problem is when I close my Excel file and I want to reopen it again (for the second time), there's no single sign my custom ribbon tab ever existed. My custom tab keeps disappearing. When I open Office RibbonX Editor again, the XML file is also empty. Is this problem fixable? I want to be able to close my Excel file, open it again, and use my custom ribbon as many times as I want.
Here is the XML code of my custom tab:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="voetbalOpstellingTab" label="Voetbalopstelling" insertBeforeMso="TabHome">
<group id="openMainWindowGroup" label="Home">
<button id="openMainWindow" image="home" size="large"
label="Open het hoofdscherm" description="Open het hoofdscherm"
screentip="Open het hoofdscherm"
onAction="ribbonTab.openMainWindow"/>
</group>
<group id="viewGroup" label="Weergeven">
<button id="openPlayersSheet" image="group" size="large"
label="Spelers weergeven" description="Geef de spelers weer"
screentip="Geef de spelers weer"
onAction="ribbonTab.openPlayersSheet"/>
<button id="openWedstrijdSheet" image="dashboard" size="large"
label="Overzicht weergeven" description="Geef het overzicht van wie, waar tijdens welke wissel heeft gespeeld weer"
screentip="Geef het overzicht van wie, waar tijdens welke wissel heeft gespeeld weer"
onAction="ribbonTab.openWedstrijdSheet"/>
</group>
<group id="actionsGroup" label="Acties">
<button id="openAddPlayerWindow" image="add-user" size="large"
label="Speler toevoegen" description="Voeg een speler toe"
screentip="Voeg een speler toe"
onAction="ribbonTab.openAddPlayerWindow"/>
<button id="openRemovePlayerWindow" image="remove-user" size="large"
label="Speler verwijderen" description="Verwijder een speler"
screentip="Verwijder een speler"
onAction="ribbonTab.openRemovePlayerWindow"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Can someone please help me?
Thanks in advance!
You are referring to some built-in controls on the ribbon. Make sure all of them are available when Excel is open. Otherwise, your custom UI will not be created.
Do you get Ribbon UI errors when your custom UI disappears?
By default, if an add-in attempts to manipulate the Microsoft Office user interface (UI) and fails, no error message is displayed. However, you can configure Microsoft Office applications to display messages for errors that relate to the UI. You can use these messages to help determine why a custom ribbon does not appear, or why a ribbon appears but no controls appear.
To show VSTO Add-in user interface errors
1. Start the application.
2. Click the File tab.
3. Click Options.
4. In the categories pane, click Advanced.
In the details pane, select Show VSTO Add-in user interface errors, and then click OK.
A security update may have caused this. See this:
https://www.youtube.com/watch?v=AhnOU-ulqNg

EXCEL UI Custom Ribbon: Two add-in for only one Custom Tab

I've got two add-in that need to create a group of buttons in a custom tab.
I'm trying to use the same Custom tab for the 2 add-ins, and so to create the two groups in this custom tab.
I've tried to set the same namespace, the same tab Id, but whatever, each time two custom tab are created, with in each one the group created by each add-in...
Is there a way to get that work?
Here is an example for the custom UI xml for the first add-in :
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="MYCOMPANYRibbonOnLoad" xmlns:x="MYCOMPANYSpace">
<ribbon startFromScratch="false">
<tabs>
<tab id="MYCOMPANYTab" label="MYCOMPANY" insertAfterMso="TabView">
<group id="IDGroup1" label="LabelGroup1">
<button id="Group1customButton1" (etc...)/>
<button id="Group1customButton2" (etc...)/>
<button id="Group1customButton3" (etc...) />
<button id="Group1customButton4" (etc...) />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
And Here is an example for the custom UI xml for the second add-in :
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="MYCOMPANYRibbonOnLoad" xmlns:x="MYCOMPANYSpace">
<ribbon startFromScratch="false">
<tabs>
<tab id="MYCOMPANYTab" label="MYCOMPANY" insertAfterMso="TabView">
<group id="IDGroup2" label="LabelGroup2">
<button id="Group2customButton1" (etc...) />
<button id="Group2customButton2" (etc...) />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I've finally found the solution :
First you have to declare your own namespace like this:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" xmlns:n="http://ISBN3-86063-989-7.com/RibbonXML" onLoad="RibbonOnLoad">
Then you need to use the idQ attribute in conjunction with your namespace alias (and not only Id attribute as I did first):
<tab idQ="n:YourCustomTab_Id" label="YourCustomTab_Name" insertAfterMso="TabView">
If you want to separate with group, you need to declare groups in the same way:
<group idQ="n:YourCustomGroup1_Id" label="YourCustomGroup1_Name">
It worked well in my case...

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:
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 && Reopen" onAction="RunMacro" imageMso="SourceControlCheckIn" size="large" screentip="Saves Document, Closes && 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>
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:
<menuSeparator id="someID" title="Test title"/>
I managed to put a menu title only on a dynamicMenu via the getContent callback, which means the xml is defined in VBA as a piece of xml string, not in the customUI xml.
Most comprehensive documentation that I found so far on customUI interfaces is on https://msdn.microsoft.com/en-us/library/dd911038(v=office.12).aspx, however the references are pointing only to 2007. This link contains a much more extensive list of controls and options with extra controls for Access as well http://www.accessribbon.de/en/?Access_-_Ribbons:Ribbon_XML___Controls

Rearranging custom buttons

I am new to programming but I tried to experiment with Excel ribbons. I am using the Custom UI Editor. I wanted to use the insertBefore and insertAfter controls to rearrange my custom buttons. If I do not use a unique namespace and insertAfterQ/insertBeforeQ at button level the order of buttons does not change, however, if I use it I cannot see the related macro (probably due to my namespace), therefore onAction will not do anything after clicking the buttons. I tried various combinations of idQ but I cannot make it work. The below example correctly executes just button 2 which is not in the namespace I specified.
A simple example:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" xmlns:x="MyNameSpace">
<ribbon>
<tabs>
<tab idQ="x:customTab" label="My Order Form" insertAfterMso="TabHome">
<group idQ="x:customGroup" label="My Order Form Tools">
<button idQ="x:customButton1" label="Clear" size="large" onAction="DeleteOrder" image="deleteorder" />
<button id="customButton2" label="Print" size="large" onAction="ResetOrder" image="resetorder" />
<button idQ="x:customButton3" label="Home" size="large" onAction="NewOrder" insertBeforeQ="x:customButton1" image="neworder" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Is there any way to make onAction work within the namespace? Or is there any other way? Many thanks, TS
Do you really need the namespace?
If you want to rearrange your own controls, just switch places in the xml:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="customTab" label="My Order Form" insertAfterMso="TabHome">
<group id="customGroup" label="My Order Form Tools">
<button id="customButton3" label="Home" size="large" onAction="NewOrder" image="neworder" />
<button id="customButton1" label="Clear" size="large" onAction="DeleteOrder" image="deleteorder" />
<button id="customButton2" label="Print" size="large" onAction="ResetOrder" image="resetorder" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
If you want to place your controls relative to built-in controls, use insertBeforeMso or insertAfterMso, like in your "customTab". From what I can tell you only need to use the namespace and idQ-ids if you combine controls from customUI-xml in different files.

Resources