<h1><strong>Creating a Custom Ribbon Tools in Excel</strong></h1>
The User Interface Editor (UI Editor) Allows you to edit the Ribbon using XML. This is extremely useful when creating a Custom Ribbon Tab, Groups &amp; Buttons. You can even limit what can be accessed on the Ribbon for certain Excel Files. This Tool is very useful for developers.

Download and Install the RibbonX UI Editor

<a href="https://github.com/fernandreu/office-ribbonx-editor/releases/tag/v1.7.0">https://github.com/fernandreu/office-ribbonx-editor/releases/tag/v1.7.0</a>

Keeping in mind, that you will need to update your .NET Core SDK.

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/NETCoreError.png"><img class="alignnone wp-image-2180 size-full" src="https://flexicoach.com.au/wp-content/uploads/2020/07/NETCoreError.png" alt="Net Core Error" width="707" height="319" /></a>

Your application will notify if it is not up to date and direct to the relevant Microsoft Page, the following link will direct you to the file.

<a href="https://dotnet.microsoft.com/download/dotnet-core/3.1">https://dotnet.microsoft.com/download/dotnet-core/3.1</a>

Once on the page you will be directed to the correct Installer. Most Windows Machines are x64 these days, but check your windows settings.

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/dotnetInstaller.png"><img class="alignnone wp-image-2179 size-large" src="https://flexicoach.com.au/wp-content/uploads/2020/07/dotnetInstaller-1024x385.png" alt="dot Net Installer " width="1024" height="385" /></a>

After you have installed the update, it will then allow the UI Editor to load.

Keep your Microsoft Excel File Closed

In order for you to Edit the Ribbon for a Specific File, it will need to be closed. The XML Code is stored in the file.

Then Start your <strong>UI Editor</strong> then <strong>File &gt; Open &gt; FileName.xlsm</strong>

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/OpenExcelFileinUIEditor.png"><img class="alignnone wp-image-2181 size-full" src="https://flexicoach.com.au/wp-content/uploads/2020/07/OpenExcelFileinUIEditor.png" alt="" width="1011" height="325" /></a>

Once the File is Opened, you can then add some sample XML Code to your code window.

To do this Click on <strong>Insert &gt; Sample XML &gt; Excel – A Custom Tab</strong>

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/CustomXMLCodeDisplayed.png"><img class="alignnone wp-image-2178 size-large" src="https://flexicoach.com.au/wp-content/uploads/2020/07/CustomXMLCodeDisplayed-1024x563.png" alt="" width="1024" height="563" /></a>

The above Code will now be displayed. What it will do is create a Table just after your home Tab.

You will notice there are some indicators as to the Tab name and Position. The code is in some way similar to HTML, With TAB being the main section, then Groups under the TAB and Buttons within Groups.
<ul>
 	<li><strong>Id</strong> – Actual Object Designation</li>
 	<li><strong>Label</strong> – Is what the User Sees</li>
 	<li><strong>Size</strong> – The Button Size</li>
 	<li><strong>ImageMso</strong> – Microsoft Designated Image Name</li>
 	<li><strong>OnAction</strong> – Action Name for the Microsoft Tool or Macro</li>
</ul>
In Our Excel VBA Course we cover all of These to help you create a Tab that is work specific.

First Rule of XML is text is Case Sensitive, even for Macro Names.

For this Tutorial we will focus on some basic changes to the Ribbon.

Firstly lets move the Ribbon Tab Contoso Tools to After the Help Tab.

To do that we change the Code from <strong>TabHome</strong> to <strong>TabHelp</strong>

<strong>insertAfterMso="TabHelp"</strong>

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/XMLTabLocation.png"><img class="alignnone wp-image-2184 size-large" src="https://flexicoach.com.au/wp-content/uploads/2020/07/XMLTabLocation-1024x113.png" alt="" width="1024" height="113" /></a>

Once we have completed that we will now make some other adjustments to the Ribbon.

For the Name Name and Id I have changed it from Contoso Tools to the following:

<strong>id="davidTab" label="David's Tab"</strong>

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/XMLTabName.png"><img class="alignnone wp-image-2185 size-large" src="https://flexicoach.com.au/wp-content/uploads/2020/07/XMLTabName-1024x113.png" alt="" width="1024" height="113" /></a>

You can use any name you desire, between the quotes.

Another adjustment I will make, is the Group Name

<strong>label="My Amazing Group Name"</strong>

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/XMLGroupName.png"><img class="alignnone wp-image-2183 size-full" src="https://flexicoach.com.au/wp-content/uploads/2020/07/XMLGroupName.png" alt="" width="871" height="65" /></a>

For this I decided to use just customGroup1 for my Id and my website as the group name. (The Group name should provide an apt description of the tools in that group.)

For the last part of this tutorial, I will focus on one of the buttons, I would like to change.

I would like add a print button. So I have adjusted the following:

The button id, renamed to “myprintButton”, label to “Print Something” and my ImageMso to “FilePrint”

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/XMLButtonCode.png"><img class="alignnone wp-image-2182 size-large" src="https://flexicoach.com.au/wp-content/uploads/2020/07/XMLButtonCode-1024x75.png" alt="" width="1024" height="75" /></a>

Note: Microsoft has specific names for each of it buttons, I found the following website handy.

<a href="http://bert-toolkit.com/imagemso-list.html">http://bert-toolkit.com/imagemso-list.html</a> or you can download the control identifiers as an Excel Worksheet. <a href="https://www.microsoft.com/en-us/download/details.aspx?id=6627">https://www.microsoft.com/en-us/download/details.aspx?id=6627</a>

Gives you a list of all of the Microsoft button images you can use. What you may find easier is to use your own images.

Assigning to Macro

For this tutorial we will assume you are already using Macros in Excel, so we will use a simple print Macro to Illustrate.

In order to run the Macro from the ribbon Button we need to associate the button with the macro itself.

Firstly we need to correct name and case of the Macro. Our Macro for this example is <strong>PrintStuff</strong>

In the VBE it will look something like this.

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/PrintMacro.png"><img class="alignnone wp-image-2186 size-large" src="https://flexicoach.com.au/wp-content/uploads/2020/07/PrintMacro-1024x265.png" alt="" width="1024" height="265" /></a>

Once you are sure of the correct Macro name, you must close the Excel File. Then you need to reopen the UI Editor.

In the Code Editor you can then add your Macro Name.

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/MacroinXML.png"><img class="alignnone wp-image-2187 size-large" src="https://flexicoach.com.au/wp-content/uploads/2020/07/MacroinXML-1024x25.png" alt="" width="1024" height="25" /></a>

<strong>Warning:</strong> You are not finished yet

So the question is <em>how to associate the Macro you have with the Button in your ribbon.</em>

To do that we need to use the general call back feature in the UI Editor.

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/CallbackUIEditor.png"><img class="alignnone wp-image-2188 size-large" src="https://flexicoach.com.au/wp-content/uploads/2020/07/CallbackUIEditor-1024x655.png" alt="" width="1024" height="655" /></a>

The above code <strong>control As IribbonControl</strong> must be pasted into your bracket () section of your Macro.

So save and close your UI Editor and Reopen your Excel File.

Open up your VBE, and View your Module with your Macro, you would like to associate.

<a href="https://flexicoach.com.au/wp-content/uploads/2020/07/MacroIribbonControl.png"><img class="alignnone wp-image-2189 size-large" src="https://flexicoach.com.au/wp-content/uploads/2020/07/MacroIribbonControl-1024x165.png" alt="" width="1024" height="165" /></a>

Once this is completed, you have successfully associated the Macro with a Button on your new Custom Ribbon Tab.

For further information or assistance, contact us on <a href="mailto:coach@flexicoach.com.au">coach@flexicoach.com.au</a>