2

我有一个要添加自定义ribbonX 按钮的xlam 文件。

我使用自定义 UI 编辑器,并使用这个 xml 它“工作”。

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon>
        <tabs>
            <tab id="Tab1" label="LeaveReport">
                <group id="Group1" label="Formatering">
                    <button id="Button1" imageMso="ChartSwitchRowColumn" size="large"/ >
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

但是,如果我添加 onaction 以使按钮执行某些操作,它根本不会加载。这意味着选项卡和按钮根本不存在。

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon>
        <tabs>
            <tab id="Tab1" label="LeaveReport">
                <group id="Group1" label="Formatering">
                    <button id="Button1" imageMso="ChartSwitchRowColumn" size="large"/ onAction="formatera_for_pivot_tabell()"/ >
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

我也试过没有().
我在这里做错了什么?没有动作的按钮是没用的:-/

4

1 回答 1

1

要使您的自定义功能区 UI 正常工作,您必须:

  1. 在不带括号的功能区 XML 中指定功能区回调。

    onAction="formatera_for_pivot_tabell"
    
  2. XML 命名空间应该被更新并且看起来像下面这样:

    xmlns="http://schemas.microsoft.com/office/2009/07/customui"

  3. 在代码隐藏文件中定义回调。

    • C#:void OnAction(IRibbonControl control)
    • VBA:Sub OnAction(control As IRibbonControl)
    • C++:HRESULT OnAction([in] IRibbonControl *pControl)
    • 视觉基础:Sub OnAction(control As IRibbonControl)

它应该具有以下文章中指定的签名:

于 2018-05-27T23:43:46.687 回答