spences10
spences10

Reputation: 590

VBA Remove Custom Toolbar from Ribbon Excel 2013

I have somehow managed to create a custom tool-bar on Excel which I can't seem to get rid of either in code or via the options

I can disable the ribbon but then can see other ribbon custom tool bars

enter image description here

How can I loop through the menu options for the Add-Ins menu and delete what appears to be just a group here in the image??

Upvotes: 4

Views: 6159

Answers (1)

Cindy Meister
Cindy Meister

Reputation: 25663

The Add-ins Ribbon tab will appear if a workbook containing CommandBar customizations is opened or being loaded as an add-in. CommandBar is the VBA object representing the old menus and toolbars (pre 2007 / pre Ribbon).

This tab also appears if code has run that uses CommandBar objects to create old-style menus and toolbars or add controls to existing ones built into the Office application. As I recall, the "Custom Toolbars" group contains all non-built-in toolbars that have been defined (they don't appear in separate groups).

The following macro I have in my archives for looping all CommandBar objects in the application. If they're not built-in (come with the product) then the information about them is written to the VBA Editor Immediate Window (Ctrl+G) and they're deleted. Built-in commandbars are reset to the installation default - changes to the default will also show up in the Add-ins tab.

Sub DetermineNonBuiltinCommandBars()
    Dim cb As Office.CommandBar

    For Each cb In CommandBars
        If Not cb.BuiltIn Then
            Debug.Print cb.Context & ", " & cb.Name
            cb.Delete
        Else
            cb.Reset
        End If
    Next
End Sub

Upvotes: 8

Related Questions