自定义用户界面编辑器创build一个从Addin内部调用macros的button

我试图让我的Excel插件添加一个自定义button启用function区。 该button应该调用保存在插件中的子。 我正在使用自定义用户界面编辑器,并按照此处列出的方法http://www.rondebruin.nl/win/s2/win001.htm 。 它已经创build了button,但是当我点击button时,它不会调用macros。 它给出“错误的参数数量或无效的属性分配”的错误。 macros本身工作正常,所以我认为这是我如何写button的问题。 任何想法,我在做什么错? 下面的代码是UI编辑器中的代码。

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon> <tabs> <tab idMso="TabHome" > <group id="customGroup1" label="My Group" insertAfterMso="GroupEditingExcel"> <button id="customButton1" label="Delete Totals" size="large" onAction="DeleteBoldTotals" imageMso="HappyFace" /> </group> </tab> </tabs> </ribbon> </customUI> 

另一个变种我试过了,这使得button甚至不出于某种原因是;

 <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon> <tabs> <tab idMso="TabHome" > <group id="customGroup1" label="My Group" insertAfterMso="GroupEditingExcel"> <button id="customButton1" label="Delete Totals" size="large" onAction=Application.Run "DeleteBoldTotals" imageMso="InkEraseMode" /> </group> </tab> </tabs> </ribbon> </customUI> 

我需要调用的macros是:

 Option Explicit Sub DeleteBoldTotals() Dim vFIND As Range, vFIRST As Range, delRNG As Range Dim ws As Worksheet On Error Resume Next For Each ws In ActiveWorkbook.Worksheets Set vFIND = ws.Cells.Find("Total", LookIn:=xlValues, LookAt:=xlPart) If Not vFIND Is Nothing Then Set vFIRST = vFIND Do If vFIND.Font.Bold = True Then If delRNG Is Nothing Then Set delRNG = vFIND Else Set delRNG = Union(delRNG, vFIND) End If Set vFIND = ws.Cells.FindNext(vFIND) Loop Until vFIND.Address = vFIRST.Address If Not delRNG Is Nothing Then delRNG.EntireRow.Delete xlShiftUp End If Set vFIND = Nothing Set vFIRST = Nothing Set delRNG = Nothing End If Next ws End Sub 

第一个是正确的。 在你需要的子名称中:

 Sub name(rib as iRibbonControl)