Adding a button to a 3rd party ribbon tab addin

痞子三分冷 提交于 2020-01-17 03:50:34

问题


I have a 3rd party addin in word 2010 and do not have access to the source code. The addin adds a new ribbon tab and many groups in the ribbon tab generated by the 3rd party addin.

I understand how to use vb2013 to create my own new ribbon tab etc. My question is, is it possible for me a create a new word 2010 addin, which somehow gets a handle on the 3rd party addin's ribbon tab and adds a button to one of the groups within the 3rd parties ribbon tab?

So basically, if the 3rd party addin is loaded in word, the user will get the 3rd party ribbon tab. If the 3rd party addin plus my possible new addin is added to word, the user should get the 3rd party ribbon, plus my new button generated by my personal addin, which somehow appears in the 3rd party ribbon tab.

Is this possible?


回答1:


According to Microsoft this is only possible if you have access to the source code of both add-ins.

How do I create two add-ins that add items to the same group or tab?

The idQ property of controls exists to enable multiple add-ins to share containers, such as custom tabs and groups. In the following VBA example, two Excel add-ins share the same "Contoso" group on the add-ins tab; each adds one button to it. The key is specifying the same unique namespace in the <customUI> tag. Then, controls can reference this namespace by using idQ.

CustomUI XML for add-in 1:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" 
  xmlns:x="myNameSpace" >
  <ribbon>
    <tabs>
      <tab idMso="TabAddIns">
        <group idQ="x:Contoso" label="Contoso">
          <button id="C1" label="Contoso Button 1" size="large" 
            imageMso="FileSave" onAction="c_action1" />
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

CustomUI XML for add-in 2:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" 
  xmlns:x="myNameSpace" >
  <ribbon>
    <tabs>
      <tab idMso="TabAddIns">
        <group idQ="x:Contoso" label="Contoso">
          <button id="C2" label="Contoso Button 2" size="large" 
            imageMso="FileSave" onAction="c_action2" />
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

If you use a COM add-in to customize the Fluent UI, the namespace name must be the ProgID of the COM add-in, but the behavior is otherwise the same. When you use a shared add-in, the ProgID is AddInName.Connect. When you use Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System (Visual Studio 2005 Tools for Office Second Edition) to create the add-in, the ProgID is the name of the add-in.

So, unless the other add-in you are trying to piggyback has set up their ribbon using a namespace and the idQ-tag, it is unlikely that you'll be able to put your controls within it's ribbon groups/tabs.



来源:https://stackoverflow.com/questions/23787108/adding-a-button-to-a-3rd-party-ribbon-tab-addin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!