我为Excel 2010编写了4到5个宏,现在我想将所有这些宏添加到功能区中的自定义选项卡中作为按钮。但我想将所有宏安装为一个完整的包(或加载项)。我已经在Visual Studio的帮助下通过创建一个CustomUI包成功安装了一个宏,但我不知道如何将其他宏添加到同一个加载项中。
答案 0 :(得分:0)
这取决于您存储宏的位置。例如,如果您的宏保存在模块中(在外接程序文件中),那么您将添加一个事件处理程序来调用CustomUI中指定的函数。例如,我有两个宏,一个名为'PricingTaxable',一个名为'PricingPerformance'。
模块中的事件处理程序:
Sub PricingTaxable_eventhandler(control As IRibbonControl)
PricingTaxable
End Sub
Sub PricingPerformance_eventhandler(control As IRibbonControl)
PricingPerformance
End Sub
CustomUI XML代码(找到事件处理程序和函数名称以了解要做什么):
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="customTab" label="Pricing" insertAfterMso="TabHome">
<group id="customGroup1" label="Taxable Income">
<button id="customButton1" label="Taxable Income" size="large"
onAction="PricingTaxable_eventhandler" imageMso="PivotTableLayoutReportLayout" />
</group>
<group id="customGroup2" label="Performance Sheets">
<button id="customButton2" label="Performance" size="large"
onAction="PricingPerformance_eventhandler" imageMso="ChartTrendline" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
请参阅此处获取更多帮助:https://erpcoder.wordpress.com/2012/05/30/how-to-create-a-custom-ribbon-addin-for-excel-2010/