none
Unable to add elements to the Outlook Ribbon 'TabMessage' RRS feed

  • Question

  • I am developing a VSTO plugin for Outlook 2017. Preferably this plugin can work with 2010. In this plugin I like to add two buttons to the Outlook interface. One in the Start ribbon ('TabMail') and one in the Message Ribbon of editing e-mails. I have managed to get the first one working using the designer a while ago but the second turns out to be a problem. According to most sources I should target the built-in 'TabMessage' id. Doing this does nothing.

    I found this forum post (https://social.msdn.microsoft.co - m/Forums/en-US/865ee885-cc0b-4273-bd2c-257878065140/outlook-addin-add-ribbon-to-message-tab-in-the-same-window-as-the-explorer?forum=vsto (broke up the link because my account is not verified yet) and tried the suggestion. I put the customized XML in a resource file. I created a new Ribbon in the designer and changed it so that all steps from the answer match. Now however all my references to the to ribbons, become null. I require both Ribbons to be present in the 'Start' method of the ThisAddIn.cs class. 

    System.NullReferenceException: 'Object reference not set to an instance of an object.'

    I do not get any other exception or notification. Once I remove the override method from the ThisAddIn.cs class the program works as usual, albeit with only the button in the Start ribbon.

    Can someone help me with this problem? Thanks in advance

    Tuesday, June 18, 2019 8:31 AM

All replies

  • Hello Elwin,

    There are two ways for creating a custom ribbon tab in Office applications (in VSTO add-ins):

    1. Walkthrough: Create a custom tab by using the Ribbon Designer

    2Walkthrough: Create a custom tab by using Ribbon XML

    Unfortunately the ribbon designer doesn't allow to set multiple contexts. But you can add few and return appropriate markup in the GetCustomUI method depending on the context passed as a parameter. Or just use a raw XML markup. Please remember that ribbon designers allow to export the custom UI to the XML file which can be used later.

        public string GetCustomUI(string ribbonID)
        {
            string ribbonXML = String.Empty;
    
            if (ribbonID == "Microsoft.Outlook.Mail.Compose")
            {
                ribbonXML = GetResourceText("Trin_RibbonOutlookBasic.Ribbon1.xml");
            }
    
            return ribbonXML;
        }


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, June 18, 2019 6:00 PM
  • Hello Eugene,

    I have tried your suggestions but to no avail. The only difference with what I already have is the ID.

    All ribbon references are still null at runtime in the 'OnStart' method of my 'ThisAddIn' class.

    Wednesday, June 19, 2019 8:28 AM
  • Elwin,

    Did you try to go through any walkthrough mentioned in my previous post?


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Wednesday, June 19, 2019 2:56 PM
  • Yes I have. I followed those to develop my outlook plugin in the firs place.
    Wednesday, June 19, 2019 6:27 PM
  • I still have not found a solution.
    Tuesday, July 2, 2019 6:34 AM
  • All ribbon references are still null at runtime in the 'OnStart' method of my 'ThisAddIn' class.

    It seems you mixed both approaches (ribbon designer and a pure XML markup) in the add-in. No ribbon references should be available at startup. You should deal only with callbacks.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, July 2, 2019 7:06 AM
  • Then given my requirements it is impossible. I must have references to the ribbons at startup.
    • Marked as answer by ElwinBran Tuesday, July 2, 2019 7:25 AM
    • Unmarked as answer by ElwinBran Tuesday, July 2, 2019 7:45 AM
    Tuesday, July 2, 2019 7:25 AM
  • Marking your own posts as answers don't make any sense there. Moreover, it doesn't correspond to your initial post there.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, July 2, 2019 7:45 AM