XML Ribbon in Outlook - make it appear on a specific window

怎甘沉沦 提交于 2019-12-03 17:15:30

This depends on the method you use to create the addin and ribbon. If you are using the

IRibbonExtensibility.GetCustomUI(string RibbonId)

method you could accomplish this by only returning the ribbon xml if the RibbonId parameter has the value

"Microsoft.Outlook.Explorer"

Edit

Following change in your code might work:

public string GetCustomUI(string ribbonID)
{
  if (ribbonID == "Microsoft.Outlook.Explorer")
    return GetResourceText("testingOLaddin2.Ribbon1.xml");

  return null; // if problems here, try return string.Empty
}

Your GetCustomUI(string RibbonId) Is called by Outlook once you implemenent CreateRibbonExtensibilityObject() in the ThisAddIn class to return a new instance of your ribbon class. The ribbon class is where you reference the XML (in GetCustomUI).

For the XML itself, you will need to reference each Outlook explorer type individually. Unfortunately, there isn't an overarching way to specify "all explorers" in the Ribbon XML syntax, as far as I know.

Here are some examples referencing the Mail and Calendar explorers:

<?xml version="1.0" encoding="UTF-8"?>
<customUI  xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon>
    <tabs>
      <tab idMso="TabCalendar">
      <!-- Calendar tab controls go here -->
      </tab>
      <tab idMso="TabMail">
      <!-- mail tab controls go here -->
      </tab>
    </tabs>
  </ribbon>
</customUI>

Microsoft does give some hint about idMso attributes for built-in tabs, but unfortunately it's buried in this Excel spreadsheet: link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!