在 VBA 中将自定义组添加到 Excel 功能区
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17616748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add a Custom Group to Excel Ribbon in VBA
提问by Jake
I found code for adding custom buttons to the add-ins menu of the ribbon in Excel 2010.
我找到了将自定义按钮添加到 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.
我正在尝试使此自定义组可用于特定工作簿,这就是我在 VBA 中进行此操作的原因。
回答by oneindelijk
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
而 csToolBarName 实际上是功能区中组的名称
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