1

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.

Community
  • 1
  • 1
Jake
  • 19
  • 1
  • 1
  • 7
  • 3
    you need to alter the XML of the file: http://www.rondebruin.nl/win/s2/win001.htm – JosieP Jul 12 '13 at 14:13
  • Unless you want that to be general on your isntallation of excel, then you right click the ribbon and "Customize the ribbon" – Julien Marrec Jul 12 '13 at 14:19
  • I'm trying to have this costum group only be available for a particular workbook, which is why i'm doing it in VBA – Jake Jul 12 '13 at 14:20
  • 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 VBA – Jake Jul 12 '13 at 14:29
  • 1
    I don't think you can do it in VBA. You might check out Andy Pope's VBA solution http://www.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 Jul 12 '13 at 15:29
  • I managed to get the permissions to install JosieP's reccomended program. Works beautifully. Thanks everyone for you help! – Jake Jul 12 '13 at 18:07
  • In case you googled and ended up here: the answer is at http://stackoverflow.com/questions/8850836/how-to-add-a-custom-ribbon-tab-using-vba/22524350#22524350 – Jan Wijninckx Mar 20 '14 at 06:07

1 Answers1

1

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
Community
  • 1
  • 1
oneindelijk
  • 606
  • 1
  • 6
  • 18
  • 2
    Other helpful resources: http://msdn.microsoft.com/en-us/library/office/aa141001(v=office.10).aspx http://stackoverflow.com/questions/5665270/excel-vba-commandbar-onaction-with-params-is-difficult-does-not-perform-as-exp – oneindelijk Sep 03 '13 at 15:25