问题描述
我已经为Excel 2010编写了大约4到5个宏,现在我想将所有这些宏作为按钮添加到功能区的自定义"选项卡中.但是我想将所有宏作为一个完整的软件包(或加载项)安装.通过在Visual Studio的帮助下创建CustomUI程序包,我已经成功安装了一个宏,但是我不知道如何将其他宏添加到同一加载项中.
I have written some 4 to 5 macros for Excel 2010, now I want to add all of these macros into a Custom Tab in the Ribbon as buttons. But I want to install all the macros as one complete package (or add-in). I have successfully installed one macro by creating a CustomUI package with the help of Visual Studio, but I don't know how to add other macros to the same add-in.
推荐答案
这取决于您将宏存储在何处.例如,如果您的宏保存在模块中(在加载宏文件中),那么您将添加一个事件处理程序,以调用CustomUI中指定的函数.例如,我有两个宏,一个叫做"PricingTaxable",另一个叫"PricingPerformance".
It depends on where you've stored your macro. For instance if your macro is saved in a module (within the Add-in file), then you would add an event handler to call the function as specified in the CustomUI. For example I have two macros, one called 'PricingTaxable' and one called 'PricingPerformance'.
模块中的事件处理程序:
Events handlers in module:
Sub PricingTaxable_eventhandler(control As IRibbonControl)
PricingTaxable
End Sub
Sub PricingPerformance_eventhandler(control As IRibbonControl)
PricingPerformance
End Sub
以及CustomUI XML代码(找到事件处理程序和函数名称以知道要做什么):
And the CustomUI XML code (find the event handler and function names to know what to do):
<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/
Refer here for more help: https://erpcoder.wordpress.com/2012/05/30/how-to-create-a-custom-ribbon-addin-for-excel-2010/
这篇关于如何将多个VBA宏合并到一个Excel加载项文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!