locked
FAQ Item: How do I add a group to a built-in Tab in Word Ribbon and how do I add a tab before a built-in Tab? RRS feed

  • Question

  • How do I add a group to a built-in Tab in Word  Ribbon and how do I add a tab before a built-in Tab?
    Sunday, June 20, 2010 12:26 PM

Answers

  • In Visual Studio Tools for Office, we can use Ribbon (XML) or Ribbon (Designer) to customize the Office UI ribbon. 

    1. For Ribbon (XML) approach, add a new item of Ribbon (XML) to the Add-in project. Then, we can customize the ribbon.xml like the following,

    <?xml version="1.0" encoding="UTF-8"?>

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

      <ribbon>

        <tabs>

          <tab idMso="TabInsert">

            <group id="group1" insertBeforeMso="GroupFont">

              <button id="button1" size="large" label="button1"

                       onAction="OnClick" imageMso="L"></button>

            </group>

          </tab>

          <tab id="TabAddIns" label="Tab1" insertBeforeMso="TabInsert">

            <group id="group2"

                   label="group2">

            </group>

          </tab>

        </tabs>

      </ribbon>

    </customUI>

     

    The idMso property is used to find the built-in Tab/Group/Control. The above ribbon.xml adds a group into the built-in Tab Insert. It also adds a tab before the Tab Insert.


    2. For Ribbon (Designer) approach, we need to add a new item of Ribbon (Visual Designer). To add a group to a built-in Tab (Insert Tab), we can follow the following steps,

    1.      Click the TabAddins (Built-In) tab to select it.

    2.      In the Properties window, expand the ControlId property, and then set OfficeId to TabInsert. Then we can drag a button onto the tab Insert’s default group.

    3.      Click the group1 to select it.

    4.      In the Properties window, expand the Position property, click the drop-down arrow next to the PositionType property, and then click BeforeOfficeId.

    5.      Set the OfficeId property to GroupFont.

    To insert a custom tab before a built-in tab, click this Ribbon to select it. By clicking Tab property in Properties window, open Tab Collection Editor dialog, and add a tab to this Ribbon. In Properties window of this added tag,

    1.      Expand the Position property, click the drop-down arrow next to the PositionType property, and then click BeforeOfficeId.

    2.      Set the OfficeId property to TabInsert.

    • Marked as answer by MSDN FAQ Sunday, June 20, 2010 12:26 PM
    Sunday, June 20, 2010 12:26 PM