gpt4 book ai didi

excel - 自定义ribbonx XML onAction使其无法加载

转载 作者:行者123 更新时间:2023-12-02 22:32:45 24 4
gpt4 key购买 nike

我有一个 xlam 文件,我想向其中添加自定义 RibbonX 按钮。

我使用自定义 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>

我也尝试过不使用 ()
我在这里做错了什么?没有操作的按钮是毫无用处的:-/

最佳答案

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

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

    onAction="formatera_for_pivot_tabell"
  2. XML 命名空间应更新并如下所示:

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

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

    • C#:void OnAction(IRibbonControl 控件)
    • VBA:Sub OnAction(控件作为 IRibbonControl)
    • C++:HRESULT OnAction([in] IRibbonControl *pControl)
    • Visual Basic:Sub OnAction(控件作为 IRibbonControl)

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

关于excel - 自定义ribbonx XML onAction使其无法加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46520689/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com