//Create callback methods here. For more information about adding callback methods, visit https://go.microsoft.com/fwlink/?LinkID=271226

        public void Ribbon_Load(Office.IRibbonUI ribbonUI)
        {
            try
            {
                this.Ribbon = ribbonUI;
            }
            catch (Exception PobjEx)
            {
                MessageBox.Show(PobjEx.ToString());
            }
        }
        public string GetCustomUI(string ribbonID)
        {
            try
            {
                LoadConfiguration(); // load the RemovedCustomizations.txt
                LoadNamespaceInfo(); // load each Outlook account namespace

                // load the base ribbon from resources
                string LstrRibbonXml = GetResourceText("RemoveOfficeWebAddin.DisableWebAddinsRibbon.xml");

                // -------------------
                // CREATE THE TABSETS
                // -------------------
                string LstrTabSetsXml = WriteTabSetXml();
                if (!string.IsNullOrEmpty(LstrTabSetsXml))
                {
                    // wrap in the contextual tab tab
                    LstrTabSetsXml = "<contextualTabs>\n"
                                     + LstrTabSetsXml +
                                     "</contextualTabs>\n";
                    LstrRibbonXml = LstrRibbonXml.Replace(REMOVE_CONTEXTTABS_COMMENT, LstrTabSetsXml);
                }

                // -------------------
                // CREATE TABS/GROUPS
                // -------------------
                // Now write all the tabs alone without groups
                string LstrTabsXml = WriteTabsXml(null, true);
                // Now write all the tabs with groups
                LstrTabsXml += WriteTabsXml();
                if (!string.IsNullOrEmpty(LstrTabsXml))
                {
                    LstrTabsXml = "<tabs>\n" +
                                  LstrTabsXml +
                                  "</tabs>\n";
                    LstrRibbonXml = LstrRibbonXml.Replace(REMOVE_TABS_COMMENT, LstrTabsXml);
                }

                // -------------------
                // NAMESPACE ADD
                // -------------------
                // add the namespaces to the root of the ribbon note
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(LstrRibbonXml);
                XmlNode ele = doc.DocumentElement.GetElementsByTagName("ribbon")[0];
                // append the attributes for each namespace for each UID we found / per account
                foreach (KeyValuePair <string, string> kvp in MobjAccountUIDs)
                {
                    XmlAttribute attr = doc.CreateAttribute("xmlns:" + kvp.Key);
                    attr.Value = kvp.Value;
                    ele.Attributes.Append(attr);
                }
                LstrRibbonXml = doc.OuterXml;

                // -------------------
                // RETURN XML
                // -------------------
                // all done - return the results
                return(LstrRibbonXml);
            }
            catch (Exception PobjEx)
            {
                // NOTE: All functions throw exceptions up here, thus this is
                //       the only error handler. Show the exception info:
                MessageBox.Show("Ribbon customization failed to load: \n\n" + PobjEx.ToString(),
                                "Disable Web Add-ins", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }