在 Excel 2010 中添加基本功能区的 VBA 代码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13125751/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 18:17:26  来源:igfitidea点击:

VBA code to add a basic ribbon in Excel 2010?

excelvbaexcel-2007ribbonexcel-2010

提问by mezamorphic

I have used products to write ribbons for Excel in C# (addin express) but I need to know how to produce a ribbon using vba. Would someone be able to provide me with some code that inserts an additional ribbon into the toolbar for this?

我已经使用产品在 C# (addin express) 中为 Excel 编写功能区,但我需要知道如何使用 vba 生成功能区。有人可以向我提供一些代码来为此在工具栏中插入额外的功能区吗?

By ribbon I mean where it says "Formulas", "Data", "Review" etc

我所说的功能区是指它上面写着“公式”、“数据”、“评论”等的地方

回答by Olle Sj?gren

You can customize the ribbon in Excel using a combination of XML and VBA.

您可以使用 XML 和 VBA 的组合在 Excel 中自定义功能区。

A good starting-point for customizing the ribbon: http://msdn.microsoft.com/en-us/library/office/aa338202%28v=office.12%29.aspx(The title says Office 2007 but it will work for Office 2010 as well)

自定义功能区的一个很好的起点:http: //msdn.microsoft.com/en-us/library/office/aa338202%28v=office.12%29.aspx(标题说 Office 2007 但它适用于Office 2010 也是如此)

Another good source is the one nutsch mentioned in his comment.

另一个很好的来源是他的评论中提到的一个 nutsch 。

There is also a free application that helps you design and validate the XML to modify the ribbon called the "Custom UI Editor For Microsoft Office": http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2006/05/25/customuieditor.aspx

还有一个免费的应用程序可以帮助您设计和验证 XML 以修改名为“Microsoft Office 的自定义 UI 编辑器”的功能区:http: //openxmldeveloper.org/blog/b/openxmldeveloper/archive/2006/05/25 /customuieditor.aspx

回答by Jan Wijninckx

There is a simple trick to it - the xml is to be included in your .xlsm file.

有一个简单的技巧 - xml 将包含在您的 .xlsm 文件中。

See this link How to add a custom Ribbon tab using VBA?

请参阅此链接 如何使用 VBA 添加自定义功能区选项卡?