Excel Hide/Show all tabs on Ribbon except custom tab

How can I hide and show all the standard Excel ribbon tabs using VBA (not XML)

The answer is “YOU CAN’T“.

AFAIK, you can’t do that using VBA. Unfortunately VBA doesn’t expose the tabs. The only options that you have are as shown in the image below

enter image description here

So you can work with the commandbar, commandbarButton, commandbarComboBox etc…

You can say that Set cbar = Application.CommandBars("Ribbon") but after that, the problem that you will face is how to get a handle for the tabs.

What you can do with the Ribbon using VBA:

  • Determine whether a particular control is Enabled/Visible/Pressed(Toggleboxes/CheckBoxes)
  • Get a control’s label, screen tip, or supertip Display the image associated with a
    control.
  • Execute a particular control.

What you can’t do with the Ribbon using VBA:

  • Determine which tab is currently selected.
  • Activate a particular tab.
  • Hide a particular tab
  • Add a new tab.
  • Add a new group to a tab.
  • Add a new control.
  • Remove/Disable/Hide a control.

You can however use XML to achieve what you want. For example

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon>
        <tabs>
            <tab idMso="TabReview" visible="false" />
        </tabs>
    </ribbon>
</customUI>

But I guess you do not want to go via the XML Route.

Leave a Comment