0
votes

I have started writing an outlook add-in. I would like to add some buttons/tabs when user is writing new e-mail or responding to some. I know that I need to change ribbon type, to be able to place those new controls in given situations, but is it possible to do it without ribbon designer? I prefer not to user ribbon designer (and write manually all code needed), but don't know how to do it without it and not sure if it possible.

EDIT: There is a little misunderstood.

I know how to edit/create office ribbon for Excel/Word/Powerpoint etc. The problem is related to Outlook, because in outlook there is multiple "views". For Excel/Word/Powerpoint there is one "type" of ribbon. Depending on the ribbontype in Outlook, it is shown in different view. I couldn't find where I could specify it in case of creating ribbon manually.

I've found something that in MS documentation:

public string GetCustomUI(string ribbonID)
{
    string ribbonXML = String.Empty;

    if (ribbonID == "Microsoft.Outlook.Mail.Compose")
    {
        ribbonXML = GetResourceText("Trin_RibbonOutlookBasic.Ribbon1.xml");
    }

    return ribbonXML;
}
3

3 Answers

0
votes

You can use Ribbon XML However as far as I know is not as straightforward, so you should think twice whether you want to go this route.

Also from: Ribbon overview

Ribbon (XML) item Use the Ribbon (XML) item if you want to customize the ribbon in a way that is not supported by the Ribbon (Visual Designer) item. Use the Ribbon (XML) item to customize the ribbon in the following ways:

  • Add built-in groups to a custom tab or built-in tab.

  • Add built-in controls to a custom group.

  • Add custom code to override the event handlers of built-in controls.

  • Customize the Quick Access Toolbar.

  • Share a Ribbon customization between VSTO Add-in by using a qualified ID.

0
votes

You are absolutely on the right avenue - everything is possible. Moreover, the ribbon designer doesn't provide all features of the Fluent UI. If you want to achieve something more than just a static custom tab with controls in Office applications you need to use the ribbon XML. The Walkthrough: Create a custom tab by using Ribbon XML article demonstrates how to create a custom Ribbon tab by using the Ribbon (XML) item.

The Fluent UI (aka Ribbon UI) is described in depth in the following series of articles:

The How to: Export a ribbon from the Ribbon Designer to Ribbon XML article can help you to export the ribbon from the designer to Ribbon XML and edit the XML directly.

0
votes

I've found an answer: in addition to standard steps that you need to make/follow when you want to create custom office ribbon, to modify ribbon in "respond" views in Outlook you need to add something that:

       public string GetCustomUI(string ribbonID)
        {
            ribbonID = "Microsoft.Outlook.Mail.Compose, Microsoft.Outlook.Post.Compose, Microsoft.Outlook" +
".Response.Compose, Microsoft.Outlook.Response.Read, Microsoft.Outlook.Sharing.Co" +
"mpose";

            return GetResourceText("Outlook_Auto_Phrases.Ribbon1.xml");
        }

Plus in ribbon file:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <ribbon  >
    <tabs >
      <tab idMso="TabInsert" >
        <group id="GpAutoPhrases" label="DTP Add-in" >
          <button id="BtnShowAutoPhrasesPane" onAction="BtnShowAutoPhrasesPane_Click" supertip="This will allow you insert saved phrases" label="Auto Phrases" size="large" getImage="GetMailImage" />
        </group>
      </tab>
    </tabs>
    <contextualTabs>
      <tabSet idMso="TabComposeTools">
        <tab idMso="TabMessage">
          <group id="GpAutoPhrasesCT" label="DTP Add-in">
            <button id="BtnShowAutoPhrasesPaneCT" onAction="BtnShowAutoPhrasesPane_Click" supertip="This will allow you insert saved phrases" label="Auto Phrases" size="large" getImage="GetMailImage" />
          </group>
        </tab>
      </tabSet>
    </contextualTabs>
  </ribbon>
</customUI>