2

我正在运行 2016 独立 Excel(32 位版本)。我一直在构建自定义功能区,到目前为止一切都很好。文档非常流畅且写得很好。但是,我找不到任何方法来包含菜单“部分标题”,如下所示:

在此处输入图像描述

具体参考图片中的部分标题(即“单元格大小”、“可见性”等)。我已经看到其他加载项模拟了这一点,除非它们是 COM 加载项。这是我参考的文档:https ://msdn.microsoft.com/en-us/library/dd911038(v=office.12).aspx

是不是已经过时了?我尝试将“带标题的菜单”添加到我的项目中,但这甚至不起作用。我也尝试过添加<labelControl />,当 labelControl 位于菜单中时,功能区甚至不会加载。

此外,我的 Excel 版本甚至不会显示,<dialogBoxLauncher>所以我担心有些东西与我的 Excel 版本不兼容。我很容易遵循文档,其他一切都很好。我什editBox至在我使用的功能区中有一个,并且没有遇到任何 91 错误。所以我知道这不是我。

任何人都可以使用提供的 API 复制它吗?我的功能区是用 XML 构建的,所以我尽可能地减少了错误的可能性,这是我的问题吗?是否应该有专门为章节标题实现的运行时代码?


我的设置的简短片段

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad">

<ribbon>
<tabs>
<tab idMso="TabHome">        

<group id="GroupTextTools" insertAfterMso="GroupFont" label="Text Tools">
    <gallery  id="textcase_gallery" label="Case Select" columns="1" size="large" imageMso="WordArtInsertDialogClassic" onAction="TextCase_SwitchCase" >
        <item id="textcase_CapsButton" imageMso="TextAllCaps" label="Uppercase" screentip="Changes selected cells to all uppercase" />
        <item id="textcase_ProperButton" label="Propercase" imageMso="ChangeCaseDialogClassic" screentip="Changes selected cells to proper case" />
        <item id="textcase_LowerButton" label="Lowercase" imageMso="FontSizeDecrease" screentip="Changes selected cells to all small case" />
    </gallery>
</group>
</tab>

<tab id="CustomTab" label="*removed*" insertAfterMso= "TabDeveloper">

<!--
  GROUP A
-->
<group id="GroupFileOptions" label="File Options">

  <button id="fileoptions_CloseButton" label="Close &amp;&amp; Reopen" onAction="RunMacro" imageMso="SourceControlCheckIn" size="large" screentip="Saves Document, Closes &amp;&amp; Reopens immediately"/>

  <menu id="exportingmenu" label="Exporting" imageMso="FileCheckOut" size="large" screentip="Exporting Options">
      <menu id="exportmenu_AsRange" label="As Range"> <!-- This is where I would like section Titles to be instead of another menu -->
        <button id="exportmenu_range_CSVCButton" label="To CSV w/commas"/>
        <button id="exportmenu_range_CSVSButton" label="To CSV w/spaces"/>
        <button id="exportmenu_range_PDF" label="To PDF"/>
      </menu>
      <menu id="exportmenu_AsSheet" label="As Sheet"> <!--Goal is for this to be a section title, where I tried putting a <labelControl> -->
      </menu>
  </menu>

</group>

<!-- .... -->
</tab>
</tabs>
</ribbon>
</customUI>
4

2 回答 2

2

经过一些试验和错误,以及David Zemens对我的错误进行故障排除后的非自愿推动,我发现通过交叉引用我尝试使用它们的父元素的所有东西,唯一具有逻辑编译意义的是 a <menuSeparator>,恰好有一个“标题”属性。因此,通过设置,您可以获得一个漂亮的部分标题,如下所示:

在此处输入图像描述

<menuSeparator id="someID" title="Test title"/>
于 2017-01-12T15:32:15.567 回答
1

我设法通过 getContent 回调将菜单标题仅放在 dynamicMenu 上,这意味着 xml 在 VBA 中定义为一段 xml 字符串,而不是在 customUI xml 中。到目前为止,我在 customUI 界面上找到的最全面的文档位于https://msdn.microsoft.com/en-us/library/dd911038(v=office.12).aspx,但参考文献仅指向 2007 年。这链接包含更广泛的控件和选项列表以及 Access 的额外控件http://www.accessribbon.de/en/?Access__-_Ribbons:Ribbon_XML___Controls

于 2018-04-02T10:28:59.997 回答