【发布时间】:2021-04-06 01:36:15
【问题描述】:
所以我正在使用 Office RibbonX 编辑器和 Excel 创建自定义功能区。我想显示一个简单的下拉菜单,允许用户在三个工作表之间切换。
我不确定为什么会出错,但我一直遇到三个与每个项目的 onAction 属性相对应的错误:
Ln 8, Col 51: The 'onAction' attribute is not declared.
Ln 9, Col 51: The 'onAction' attribute is not declared.
Ln 10, Col 51: The 'onAction' attribute is not declared.
这是我的代码:
XML(customUI14.xml 文件):
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="customTab" label="DropDown" insertAfterMso="TabHome">
<group id="customGroup" label="Custom Group">
<dropDown id="dropDown1" label="Dropdown Box">
<item id="dd01" label="Sheet1" imageMso = "_1" onAction="DDOnAction" />
<item id="dd02" label="Sheet2" imageMso = "_2" onAction="DDOnAction" />
<item id="dd03" label="Sheet3" imageMso = "_3" onAction="DDOnAction" />
</dropDown>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
VBA:
Sub DDOnAction(control As IRibbonControl, id As String, index As Integer)
Select Case control.id
Case "dd01"
ActiveWorkbook.Sheets("Sheet1").Activate
Case "dd02"
ActiveWorkbook.Sheets("Sheet2").Activate
Case "dd03"
ActiveWorkbook.Sheets("Sheet3").Activate
End Select
End Sub
【问题讨论】:
标签: excel xml dropdown ribbon ribbonx