Jake
Jake

Reputation: 29

Add a Custom Group to Excel Ribbon in VBA

I found code for adding custom buttons to the add-ins menu of the ribbon in Excel 2010.

I want to add my own custom group to the home tab in the ribbon, and add some buttons to that group.

I'm trying make this custom group be available for a particular workbook, which is why I'm doing it in VBA.

Upvotes: 1

Views: 13029

Answers (1)

oneindelijk
oneindelijk

Reputation: 636

Your question is similar to this one

I've beed doing some research and I've managed to add a custom toolbar with a button. I'm trying to figure out how to address specifically that particular Ribbon bar

This script made it work (from an answer in the other thread)

Sub test()
Dim cbToolbar
Dim csToolBarName
Dim msoBarTop
Dim ctButton1
csToolBarName = "Rekenblad"
Set cbToolbar = Application.CommandBars.Add(csToolBarName, msoBarTop, True, True)

With cbToolbar
    Set ctButton1 = .Controls.Add(Type:=msoControlButton, ID:=2950)

End With

Whereas csToolBarName is actually the name of the group in the ribbon

I used this to check all the names

Sub visi()
Dim r
  For Each r In Application.CommandBars
    Debug.Print r.Name
  Next
End Sub

Upvotes: 1

Related Questions