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
Related
I tried to customize the Office ribbon for one of my Office documents, as explained in chapter "To customize the Fluent UI by using Office Open XML Formats files".
It should theoretically add a new tab and one button, but when I open this document I always get this error (NB: I activated the Office option to see errors with Backstage view (File) > Options > Advanced Options > General > Show add-in user interface errors):
Error detected in custom UI XML code ... Line 1 Column ... Error code 0x80070057 - Incorrect parameter.
Here is the popup containing the error message (NB: I have Office in French language):
And the new tab does not show up at all.
It failed with an Excel document, but I also tried to do it with Word and PowerPoint, and got exactly the same error.
Here are the changes I did to Classeur1.xlsx to add the tab (renaming its suffix to .zip, manipulating its content, and renaming it back to .xlsx):
In _rels/.rels, I added this line before added this line before </Relationships>:
<Relationship Type="http://schemas.microsoft.com/office/2006/relationships/ui/extensibility"
Target="customUI/customUI.xml" Id="customUIRelID"/>
I created customUI/customUI.xml:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="MyTab" label="My Tab">
<group id="MyGroup" label="My Group">
<button id="MyButton" label="MyButton" onAction="MyMacro"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
NB: I know that the subroutine "MyMacro" must also be created and the Excel file is to be saved as type .xlsm, but I just want to propose the minimal case to reproduce, clicking the button is not the problem here.
My Excel, Word and PowerPoint versions: Office 365, Version 2008 (build 13127.20408 Office "click-and-go").
EDIT: here is the screenshot of version (NB: 2 days after my question, it has been upgraded automatically to version 2009 Build 13231.20262), and I haven't got the error now
The error is that <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> is not valid for the version "2008" for subscription 365 -- I don't pretend that it's Office 2008, it's just what I saw, it's like now "2009" (see screenshot in my question) -- even if Steve Rindsberg doubts that versions 2008 and 2009 can appear, sorry to not have taken a screenshot -- hopefully I could find this screenshot mentioning a version "2008" in this Windows blog post:
Instead, I used the namespace <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> combined with relationship using the Relationship namespace http://schemas.microsoft.com/office/2006/relationships/ui/extensibility>:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id="MyTab" label="My Tab">
<group id="MyGroup" label="My Group">
<button id="MyButton" label="MyButton" onAction="MyMacro"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Now, I can successfully see "my tab" when I open Classeur1.xlsx:
Reason
Ron de Bruin mentioned at https://rondebruin.nl/win/s2/win001.htm, while presenting the Office RibbonX Editor, that one of the two versions must be selected:
Insert Office 2010+ Custom UI Part
Insert Office 2007 Custom UI Part
So I guess that there is a corresponding namespace according to the Office version (whatever it's under 365 subscription or not). Note that there is also a different namespace for _rels\.rels mentioned in [MS-CUSTOMUI] and [MS-CUSTOMUI2] Microsoft standards.
2010+ ([MS-CUSTOMUI2])
custom UI: <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
Source relationship: http://schemas.microsoft.com/office/2007/relationships/ui/extensibility
2007-2009 ([MS-CUSTOMUI])
custom UI: <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
Source relationship: http://schemas.microsoft.com/office/2006/relationships/ui/extensibility
(*) PS: I am not sure to have correctly tested if the combination of both namespaces for 2010 did work or not for my version "2008" with subscription 365. Steve has said in the comments that it should have worked because it's subscription 365. I can't test anymore for "2008" because my Office version was automatically upgraded to version 2009, and 2010 namespaces work.
I am trying to set a transparent icon for my Excel add-in with the RibbonX API. This is my XML:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" loadImage="gui_LoadImage">
<ribbon>
<tabs>
<tab id="CBtab" label="2019CBMaster">
<group id="visualizationGroup" label="Visualization">
<button id="btnHistogram" label ="Press here" enabled="true" screentip="Press and see how magic happens" image="icn_btnHistogram.jpg" size="large"/>
</group>
<group id="NewGroup" label="2019NewGroup" >
<box id="bxBo">
<button id="btnNew" label="Press" image="icn_btnHisto.jpg" size="large"/>
<menu id="mnMenu" image="btn_img_random.jpg">
</menu>
</box>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
this is the sub that is setting the picture: for my testing purposes, it ignores the xml parameters and simply loads a 'fixed' picture:
Sub gui_LoadImage(ImageName As String, ByRef Image)
Set Image = stdole.LoadPicture("C:\Office 2010 Developer Resources\icons\gg.ico")
End Sub
I saved gg.ico in GIMP as 24 bpp and 1 bit alpha ico file. I also tried external ico-s and they did not display as well.
As you have understood from above, the icons are not displayed as if they were completely transparent.
Could you help?
Also, is this RibbonX API still supported? I am wondering because I have difficulties doing a pretty basic thing and can find little to no documentation. If not, what are the modern frameworks for developing Excel Add-ins with customizable ribbons?
Thank you.
Custom Ribbon UI icons can be transparent. I believe they must be .png files. Here are details on the UI Ribbon icon settings, which includes transparent backgrounds.
https://learn.microsoft.com/en-us/office/dev/add-ins/design/add-in-icons
REVISION
In custom UI editor, you can import your image files and then just reference the file names in the XML code. The file type and whether or not the image itself has a transparent background is what I believe determines whether or not it appears transparently on the ribbon. This is what the XML would look like. <button id="customButton1" label="Label 1" size="large" onAction="Macro1" image="picture1" />
In looking at your XML code, I see that you have the file extension included in with the images. I do not include the file extensions with my custom image icons. In the Custom UI editor that I linked, you can add import the image file, which appears in the side pane, then you reference only the file name in the XML (no file extension). I also believe is the file type itself and whether or not the image actually has a transparent background that determines whether or not it appears transparently in the ribbon. jpg files cannot be transparent, so that may be your problem right there. If your UI editor cannot accommodate PNG files, try using GIF. The icons are so small; image quality shouldn't be an issue.
Here is an example:
<splitButton id="splitButton2" size="large" >
<button id="InsertTools" label="Insert" image="InsertTools_Transparent" />
<menu id="menu2">
<button id="buttonInsertMultiSheets" onAction="ModRibbon.Run_InsertMultipleSheets" label="Insert Multiple Sheets" screentip="Add multiple worksheets at one time. An input box will appear for you to enter the number of sheets to be added." image="WorksheetAddMultipleSheets" />
</menu>
</splitButton>
Here are some of my personal notes from when I was learning that may or may not be helpful for you.
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<backstage>
<button id="MyCustomButton1" label="My Macro"
imageMso="HappyFace" isDefinitive="true" onAction="ModRibbon.Run_Macro1"/>
<!-- 'button id' each must be unique -->
<!-- 'My Macro' is the text that will appear on your button -->
<!-- Use 'imageMso' or 'image' to include a picture on your button. -->
<!-- 'imageMso' uses built-in Office images; do not insert into this file as icons. -->
<!-- 'image' uses your own image as your button's icon. Insert it into this file as an icon. -->
<!-- 'HappyFace' is the name of the built-in Office image (for custom images, enter the file name). -->
<!-- 'ModRibbon' is the name of the VBA module in which you will paste this call-back sub. You can name this anything. -->
<!-- 'Run_' is a custom prefix added to the macro name, so you don't have to rename your macros. -->
<!-- 'Macro1' is the macro that should be run when the button is clicked. -->
</backstage>
</customUI>
With the Custom UI editor I use, the callback would be:
'Callback for buttonInsertMultiSheets onAction
Sub Run_InsertMultipleSheets(control As IRibbonControl)
End Sub
From your code, it looks like you need a call to load the image as well, so the customUI control has two callbacks:
Sub LoadImage (imageID As String, ByRef image)
Sub OnLoad(ribbon As IRibbonUI)
If you also have a [Content_Types].xml, then the default type is PNG and you need to add a line at the very end of the file, but before , and then save your changes.
<Default Extension="jpg" ContentType="application/octet-stream"/>
The recommended file format for icons on the Ribbon UI is PNG. Microsoft Office Ribbons and toolbars support ICO, BMP and ICO files. So, I'd suggest converting your VBA macros to the COM add-in where you can easily load such images.
You may find the Graphics formats for Microsoft Office add-ins article helpful. The Fluent UI is described in depth in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
I have successfully made Word VBA and VSTO Add-Ins share ribbon customizations in the past using code like this:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" xmlns:nsMvSample="Sample Namespace">
<ribbon>
<tabs>
<tab idQ="nsMvSample:TabAddIns" label="Sample Tab">
<group idQ="nsMvSample:MyGroup" label="Sample Group">
<button id="NewDocument" label="New Document" imageMso="FileNew" size="large" onAction="NewDocument_Click" supertip="Opens the Select Template dialog to create a new document."/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I'm currently getting to know the newer Office Web Add-Ins. I'd like to slowly introduce them into my solution by moving commands one at a time from VSTO to Office Javascript.
Can a VSTO Add-In share ribbon customisations with the newer Office Web Add-Ins?
Can I use the same idQ syntax? If so, how do I setup the namespace?
I'm afraid not. Office Web Add-ins use an entirely different mechanism for defining commands in the ribbon. They support a more constrained set of requirements and controls (buttons and drop-down buttons).
I've got a simple split button in my Ribbon. And under it I have two buttons in the menu.
It works well.
Now I want to extend the first button -button id="rxBtn_CreateDataFiles" - into more options,
and have another submenu extend to the right with two more choices.
What would be the syntax for it? Thanks.
<splitButton id="rxspb_CreateDataFiles" size="normal">
<button id="rxBtn_CreateDataFilesFace" label="Data Files" imageMso="ChartEditDataSource"/>
<menu id="rxmnuCreateDataFiles">
<button id="rxBtn_CreateDataFiles" label="Run EQ" onAction="QRCreateDataFiles_Click" imageMso="ExportExcel"/>
<button id="rxBtn_CreateSpecificDataFiles" label="Run Select EQ" onAction="QRCreateDataFilesForSpecific_Click" imageMso="ExportExcel"/>
</menu>
</splitButton >
I figured it out. Just need to insert another menu section in the middle. Thanks.
Here is what I would do: Create the buttons in VBA using Ribbon Commander and then export XML to a static Ribbon using .serializeToXML
With rxCustomUI.defaultInstance
With .ribbon.tabs.Add(New rxTab)
.Label = "tab"
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!