vba Excel 2010 - 在工作簿中存储功能区自定义

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

Excel 2010 - Storing Ribbon Customization in Workbook

excel-vbaribbonexcel-2010vbaexcel

提问by ThomasMcLeod

I'm new to Excel ribbon customization. What is the most straight forward way to store ribbon customization inside a workbook, so that when the workbook is closed the customization disappears without a trace?

我是 Excel 功能区自定义的新手。在工作簿中存储功能区自定义的最直接方法是什么,以便在工作簿关闭时自定义消失得无影无踪?

回答by JMax

To change the ribbon with a workbook, you need to change the XML file "inside" the xlsx file (which is nothing more but a .zip).

要使用工作簿更改功能区,您需要更改 xlsx 文件“内部”的 XML 文件(只不过是 .zip)。

Everything is very well explained here: http://www.rondebruin.nl/ribbon.htm

一切都在这里得到了很好的解释:http: //www.rondebruin.nl/ribbon.htm

Please let us know if that does not answer your question.

如果这不能回答您的问题,请告诉我们。

回答by sirplus

The most straightforward way is to right-click on the ribbon & choose customise ribbon, then look on the lower right of the box that opens, choose reset and then confirm.

最直接的方法是右键单击功能区并选择自定义功能区,然后查看打开的框的右下方,选择重置然后确认。

PS
You can also create CustomUI Ribbonsin excel by recycling your old excel toolbars!

PS
您还可以通过回收旧的excel工具栏在excel中创建CustomUI Ribbons

I must have read 500 pages on customisation and never seen the below gold anywhere. This method also lets you add a customUI Ribbon NOT LINKED TO or embedded in a workbook. :-)

我一定已经阅读了 500 页关于定制的内容,但从未在任何地方看到过下面的黄金。此方法还允许您添加未链接到或嵌入到工作簿中的自定义 UI 功能区。:-)

Undocumented feature follows:
Just open an old excel12.xlbfrom Excel 2007 in Excel Pro 2010 and a shiny new ribbon tab will appear. I have also previously created these in excel 2007 from an old 2003 Excel(X?).xlb which I have been using all the way from Excel5 if memory serves correctly.

未记录的功能如下:
只需在 Excel Pro 2010 中从 Excel 2007打开旧的excel12.xlb,就会出现一个闪亮的新功能区选项卡。我之前也从旧的 2003 Excel(X?).xlb 在 excel 2007 中创建了这些,如果内存正常,我一直在使用 Excel5。

It was not linked to an xls, so it was viewable even if no sheets were open. (Not just hidden, but actually none open or viewable in VBIDE.) Nothing in the add-ins list either.

没有链接到 xls,因此即使没有打开工作表也可以查看。(不仅隐藏,而且实际上在 VBIDE 中都没有打开或可见。)加载项列表中也没有任何内容。

I exported this customisation using Excel's utility. The beauty of this is it makes it very easy to edit the macro paths etc, as I was able to edit the names by opening the Excel Customizations.exportedUIin Notepad. Imported back into Excel using the utility.

我使用 Excel 的实用程序导出了此自定义。这样做的好处是它可以很容易地编辑宏路径等,因为我可以通过在记事本中打开Excel Customizations.exportedUI来编辑名称。使用该实用程序重新导入 Excel。

The code inside can be used as part of a standard customisation using rels etc. So if you want to add it to a workbook go right ahead, only I put a lot of general utilities in mine.

里面的代码可以用作使用 rels 等的标准定制的一部分。所以如果你想把它添加到工作簿中,直接去吧,只有我在我的里面放了很多通用实用程序。

Here are some snips of my screen to back it up:
(click for full image)

这是我的屏幕截图以进行备份:(
单击获取完整图像)