VSTO add built-in function to custom ribbon/group

后端 未结 1 1672
醉酒成梦
醉酒成梦 2021-01-21 03:25

I\'ve search for this and only been able to find the reverse (i.e. add a custom function to an existing ribbon tab/group).

We have a custom ribbon that we want to add so

相关标签:
1条回答
  • 2021-01-21 03:32

    You can't add a built-in control in the Ribbon Designer. Best you can do is to call the Excel functionality you want to use from within the event handler for your custom button.

    If you export the Ribbon to XML you can use native Office controls in the Ribbon XML definition by assigning the Control ID value to a control's idMso attribute. Note that the control type must be the same type (you can't use a dropdown instead of a toggle button, for example).

    Here's minimal Ribbon XML that shows the elements for the two buttons you ask about:

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
      <ribbon>
        <tabs>
          <tab idMso="TabAddIns">
            <group id="MyGroup"
                   label="My Group">
              <button idMso ="DecimalsIncrease"/>
              <button idMso ="DecimalsDecrease"/>
            </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>
    

    Depending on the version of Office you're targeting, you can download files of control IDs for the various Office applications. The download is an exe file that unzips to 30+ Excel files listing all (well, most of) the Control IDs. Here are the links to downloads for the current versions of Office:

    Office 2010

    Office 2013

    Office 2016

    Office 2007

    0 讨论(0)
提交回复
热议问题