Vba 如何在自定义office功能区中具有多个关联菜单

Vba 如何在自定义office功能区中具有多个关联菜单,vba,powerpoint,contextmenu,office-addins,ribbon,Vba,Powerpoint,Contextmenu,Office Addins,Ribbon,我正在尝试向Office addin for Powerpoint添加两个上下文菜单。第一个在用户右键单击幻灯片时显示,第二个在用户右键单击选定形状时显示。它们是分开工作的,下面是功能区xml: <contextMenus> <contextMenu idMso="ContextMenuShape"> <button id=".../> </contextMenu> </contextMenus> 元素是项的容器。在ribb

我正在尝试向Office addin for Powerpoint添加两个上下文菜单。第一个在用户右键单击幻灯片时显示,第二个在用户右键单击选定形状时显示。它们是分开工作的,下面是功能区xml:

<contextMenus>
<contextMenu idMso="ContextMenuShape">
    <button id=".../>
</contextMenu>
</contextMenus>

元素是
项的容器。在ribbon.xml中,您需要将所有上下文菜单项放入“contectMenus”容器中。例如:

<contextMenus>
  <contextMenu idMso="ContextMenuShape">
    <button id="id_shape" label="Label 1"/>
  </contextMenu>
  <contextMenu idMso="ContextMenuFrame">
    <button id="id_ffame" label="Label 2"/>
  </contextMenu>
</contextMenus>


要自定义上下文项的可见性,您需要使用每个上下文菜单中元素的“GetVisible”和“GetEnabled”处理程序;在本例中,这些是按钮。

谢谢@Slava,这非常有效。以前它不适用于我的原因是我有重复的ID,并且没有验证我的xml
<contextMenus>
  <contextMenu idMso="ContextMenuShape">
    <button id="id_shape" label="Label 1"/>
  </contextMenu>
  <contextMenu idMso="ContextMenuFrame">
    <button id="id_ffame" label="Label 2"/>
  </contextMenu>
</contextMenus>