none
Customizing the built-in Outlook ribbon TabContact does not work RRS feed

  • Question

  • Hi,

    I have an Outlook 2007 AddIn, placed  a ribbon in the project and customized the ribbon with the designer (only 1 group with 1 button for testing).

    I've set the RibbonType("Microsoft.Outlook.Contact"), ControlIdType ("Office") and the OfficeID ("TabFormatText") => works fine! (Tested it with just a msgbox("Hello World"))

    But I have to customize the TabContact. So I only changed the OfficeID from "TabFormatText" to "TabContact" (I changed nothing else!) -> Does NOT work -> the whole TabContact disappears.

    Then I checked the other tabs/IDs:

    - TabFormatText: works

    - TabAddIns: works

    - TabDeveloper: works

    - TabContact: NOT working

    - TabInsert: NOT working

    Any ideas, suggestions...?

     

    Thanks in advance

    Markus

     

    Friday, February 3, 2012 1:37 PM

Answers

  • Hi Markus,

     

    Thanks for posting in the MSDN Forum.

     

    I can’t reproduce your issue. The tab works fine on my side.

     

    I paste my snippet here, please check it to find different between us.

     

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
      <ribbon>
        <tabs>
          <tab idMso="TabContact" label="Let's Test it">
          </tab>
        </tabs>
      </ribbon>
    </customUI>
    

    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Reflection;
    using System.Runtime.InteropServices;
    using System.Text;
    using Office = Microsoft.Office.Core;
    
    // TODO:  Follow these steps to enable the Ribbon (XML) item:
    
    // 1: Copy the following code block into the ThisAddin, ThisWorkbook, or ThisDocument class.
    
    //  protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
    //  {
    //      return new Ribbon1();
    //  }
    
    // 2. Create callback methods in the "Ribbon Callbacks" region of this class to handle user
    //    actions, such as clicking a button. Note: if you have exported this Ribbon from the Ribbon designer,
    //    move your code from the event handlers to the callback methods and modify the code to work with the
    //    Ribbon extensibility (RibbonX) programming model.
    
    // 3. Assign attributes to the control tags in the Ribbon XML file to identify the appropriate callback methods in your code.  
    
    // For more information, see the Ribbon XML documentation in the Visual Studio Tools for Office Help.
    
    
    namespace OutlookAddIn1
    {
        [ComVisible(true)]
        public class Ribbon1 : Office.IRibbonExtensibility
        {
            private Office.IRibbonUI ribbon;
    
            public Ribbon1()
            {
            }
    
            #region IRibbonExtensibility Members
    
            public string GetCustomUI(string ribbonID)
            {
                string result = string.Empty;
                switch (ribbonID)
                {   
                    case "Microsoft.Outlook.Contact":
                        result = GetResourceText("OutlookAddIn1.Ribbon1.xml");
                    break;
                }
                return result;
            }
    
            #endregion
    
            #region Ribbon Callbacks
            //Create callback methods here. For more information about adding callback methods, select the Ribbon XML item in Solution Explorer and then press F1
    
            public void Ribbon_Load(Office.IRibbonUI ribbonUI)
            {
                this.ribbon = ribbonUI;
            }
    
            #endregion
    
            #region Helpers
    
            private static string GetResourceText(string resourceName)
            {
                Assembly asm = Assembly.GetExecutingAssembly();
                string[] resourceNames = asm.GetManifestResourceNames();
                for (int i = 0; i < resourceNames.Length; ++i)
                {
                    if (string.Compare(resourceName, resourceNames[i], StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        using (StreamReader resourceReader = new StreamReader(asm.GetManifestResourceStream(resourceNames[i])))
                        {
                            if (resourceReader != null)
                            {
                                return resourceReader.ReadToEnd();
                            }
                        }
                    }
                }
                return null;
            }
    
            #endregion
        }
    }
    

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, February 6, 2012 9:38 AM
    Moderator