Show Custom Ribbon as default item on startup

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
I'm using the Custom UI Editor to start tweaking a custom ribbon in Excel 2010 - does anyone know if there is a way to set my custom tab as the default when the file opens and always show first?

Also, is there a way to remove the default groups from my custom tab, by that I mean clipboard and font?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
First, in your XML code, you'll need to include the "on Load" callback. Then, you'll also need to set the Visible property to False for both built-in groups. So, assuming that you've added a custom tab and that you've set the ID to "CustomTab", you'll have something like this...

Note: A space has been added between "on" and Load" throughout the code, otherwise it would be interpreted as code. Therefore, remove the space from each occurrence within the code. Also, square brackets have been used instead of angled brackets for the same reason. Therefore, replace the square brackets with angled brackets.

XML Code

<customui
Code:
[customUI 
    xmlns="http://schemas.microsoft.com/office/2006/01/customui"
    on Load="on Load"]
    [ribbon ]
        [tabs ]
            [tab  idMso="TabHome" ]
                [group 
                    idMso="GroupClipboard"
                    visible="false"/]
                [group 
                    idMso="GroupFont"
                    visible="false"/]
            [/tab ]
            [tab 
                id="CustomTab"
                label="MyTab"/]
                'etc
                '
                '
            [/tab ]
        [/tabs ]
    [/ribbon ]
[/customUI ]

</customui>Then, place the following code in a regular module...

VBA Code

Code:
Option Explicit

Dim MyRibbon As IRibbonUI

Public Sub on Load(ribbon As IRibbonUI)
'
' Code for on Load callback.
'
    Set MyRibbon = ribbon
    
    MyRibbon.ActivateTab ControlID:="CustomTab"
    
End Sub

Hope this helps!
 
Upvote 0
Domenic, thanks, but the following is highlighted red;

Code:
Public Sub on Load(ribbon As IRibbonUI)
 
Upvote 0
As per my previous remarks in red, you'll need to remove the space between "on" and "Load" so that it's one word. So you'll need to remove the space between those two for each occurrence throughout the code. And, make sure that you replace the square brackets with angled brackets.
 
Upvote 0
Ahh, I see - sorry, I didn't understand that bit as I thought!
 
Upvote 0
A custom tab shouldn't have any default groups on it - only whatever you specified in the XML.
 
Upvote 0
RoryA - what I meant was to show that tab as the first one on startup, rather than 'Home' - bad description of the issue on my part.
 
Upvote 0
This worked for me, except if I set the visible to false on my groups, it would crash Excel on startup with an automation error. I tried adding a timer, didn't seem to matter. But If I didn't set visible to false, and added the ActivateTab line to the on Load sub, it works fine. Just thought I'd post in the event others stumble across the post and had any issues applying the solution.
 
Upvote 0
I'm using the Custom UI Editor to start tweaking a custom ribbon in Excel 2010 - does anyone know if there is a way to set my custom tab as the default when the file opens and always show first?

Also, is there a way to remove the default groups from my custom tab, by that I mean clipboard and font?

Yes.

[FONT=&quot]The answer to this question is embarrassingly simple. One can make the custom tab the first one on the ribbon by changing the XML <tab> line to:[/FONT]
[FONT=&quot]<tab id="tabDO" label="Coltar" insertBeforeMso="TabHome">

change out "tabDO" with the name of your tab. Note the insertBEFOREMso rather than the usual insertAFTERMso.

Hope this helps.


[/FONT]
 
Upvote 0
That will make it the first tab in the Ribbon, but it won't activate it by default when the workbook opens, which was the thrust of the question.
 
Upvote 0

Forum statistics

Threads
1,214,383
Messages
6,119,198
Members
448,874
Latest member
Lancelots

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top