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

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?

Related

How to generate callback for buttons in box grouping container in Custom UI Editor?

I am creating a custom toolbar for Excel 2010 and I am running into an problem with 2 of the buttons I have placed in a box group. For some reason they are not generating callbacks from the "onAction" command like all my others are and I am not getting any coding errors. I have been going through the markup specifications but cannot find a command that might work. Anyone see what I am doing wrong? The box group I am referring to is at the bottom of the code below - buttons labeled "ConvertToValues" and "TrimSpaces". Thanks.
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="MyCustomTab" label="Reporting">
<group id="AvtGroup" label="Actual v Target">
<button id="AvTDataPrep"
label="Data Organization"
imageMso="CreateQueryInDesignView"
size="large"
onAction="PrepAvTData" />
<button id="ChannelExport"
label="Channel Analysis Export"
imageMso="TableExportTableToSharePointList"
size="large"
onAction="ExportChannelData" />
<button id="Top50Export"
label="Top 50 Export"
imageMso="TableExportTableToSharePointList"
size="large"
onAction="ExportTop50Data" />
<button id="Top50CopyPaste"
label="Top 50 Copy/Paste"
imageMso="ImportExcel"
size="large"
onAction="CopyandPasteTop50Data" />
</group>
<group id="RMbyLocGroup" label="Route Metrics by Location">
<button id="RMDataPrep"
label="Data Organization"
imageMso="CreateQueryInDesignView"
size="large"
onAction="PrepRMData" />
</group>
<group id="ServiceMetricsGroup1" label="Service Metrics Tools">
<button id="FrequencyUpdate"
label="Frequency Update (AvT File)"
imageMso="PivotTableFormulasMenu"
size="large"
onAction="UpdateFrequencies" />
<button id="ServiceMetrics"
label="Service Metrics (AvT File)"
imageMso="DatasheetNewField"
size="large"
onAction="AddServiceMetrics" />
</group>
<group id="FormattingGroup" label="Formatting Tools">
<box id="FormattingBox" boxStyle="vertical">
<button id="ConvertToValues"
label="Convert To Values"
imageMso="ConditionalFormattingBottomNItems"
onAction="ConvertToValues" />
<button id="TrimSpaces"
label="Trim Excess Spaces"
imageMso="FormControlEditBox"
onAction="TrimSpaces" />
</box>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
The source code for the Custom UI editor is available on GitHub. You can get the latest version and run it under the debugger where you can find the answer why callbacks are not generated for controls grouped together under the box control.
As a workaround you may add ribbon callbacks manually.

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.

Double ribbon items for SplitButton

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!

Resources