1
votes

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.

1
you need to alter the XML of the file: rondebruin.nl/win/s2/win001.htmJosieP
Unless you want that to be general on your isntallation of excel, then you right click the ribbon and "Customize the ribbon"Julien Marrec
I'm trying to have this costum group only be available for a particular workbook, which is why i'm doing it in VBAJake
JosieP, that would work and sounds glorious but I'm not allowed to install any extra software on these computers, so I'm trying to figure out how to do this in purely VBAJake
I don't think you can do it in VBA. You might check out Andy Pope's VBA solution andypope.info/vba/ribboneditor.htm and see if you can borrow some source code. Otherwise, you rip open the xlsx file, edit the XML in notepad, and package it back up. That sounds horrible and terrifying, but you could do it.Dick Kusleika

1 Answers

1
votes

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