How to add a button to a pre-existing tab on ribbon (C#)?

user1675891 picture user1675891 · Sep 19, 2012 · Viewed 14.1k times · Source

I've successfully created a new tab and put it next to the pre-existing ones. Then I realized that I'll only have one button on it, so it makes more sense (for now) to put it on the Home tab. Didn't really get that to work though.

I've tried to follow the guides and walk-troughs. I've got me an XML and changed its XML to the following.

<tabs>
  <!--<tab idMso="TabAddIns">-->
  <tab idMso="TabHome">
    <group id="group1" label="Hazaa!">
      <box id="box1" />
    </group>
  </tab>
</tabs>

When I run the project I get no changes to the UI, so I guess that either:

  1. the XML is not read at all,
  2. the name TabHome is wrong (at least for Outlook 2010),
  3. the attribute idMso is wrong (at least for Outlook 2010) or
  4. other/combination of any of the mentioned.

What can I do to alter the ribbon? (Outlook 2010/VSTO/VS 2010/.NET 4).

Answer

Olle Sj&#246;gren picture Olle Sjögren · Sep 19, 2012

The attribute idMso is correct, but the id for the tab you want is TabMail. You can find a packed set of Excel-files containing lists of Office 2010 control IDs on MSDN. Then, as mentioned in a comment to the question, your sample XML may be missing the customUI and ribbon-tags. (Disclaimer: I haven't customized the ribbon in Outlook, only Word, Excel and PowerPoint, but I would guess they work the same?)

Try something like the this:

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon>
        <tabs>
            <tab idMso="TabMail">
                <group id="group1" label="Hazaa!">
                    <box id="box1" />
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>