【问题标题】:How to add custom ribbon button in Report tab of outlook如何在 Outlook 的报告选项卡中添加自定义功能区按钮
【发布时间】:2019-08-08 13:46:25
【问题描述】:

我想在 Outlook 的“报告”选项卡中添加我的自定义功能区按钮。我可以在 Outlook 的“主页”选项卡中添加功能区按钮。在这里,我附上了要添加自定义功能区按钮的图像。

谢谢

【问题讨论】:

    标签: c# outlook vsto outlook-addin


    【解决方案1】:

    屏幕截图中显示的内置标签的idMsoTabReadMessage。您只需在 GetCustomUI 回调中返回适当的功能区 XML 标记。

    Microsoft Office 应用程序调用GetCustomUI 方法来获取定义自定义功能区用户界面的 XML 字符串。

    public class Connect : Object, Extensibility.IDTExtensibility2, IRibbonExtensibility 
    ... 
    
    public string GetCustomUI(string RibbonID) 
    { 
    
       StreamReader customUIReader = new System.IO.StreamReader("C:\\RibbonXSampleCS\\customUI.xml"); 
    
       string customUIData = customUIReader.ReadToEnd(); 
    
       return customUIData; 
     }
    

    注意,有时您需要为作为参数传递的不同 ribbonID 值返回 XML 标记。在这种情况下,您将调用onLoad 回调(也适用于检查员)。

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

    请参阅Customizing a Ribbon for Outlook 了解更多信息。

    您可以在 MSDN 中的以下系列文章中阅读有关 Fluent UI(又名 Ribbon UI)的更多信息:

    请记住,默认情况下,如果 VSTO 加载项尝试操作 Microsoft Office 用户界面 (UI) 并失败,则不会显示任何错误消息。但是,您可以将 Microsoft Office 应用程序配置为显示与 UI 相关的错误消息。您可以使用这些消息来帮助确定为什么不显示自定义功能区,或者为什么显示功能区但不显示控件。有关更多信息,请参阅How to: Show Add-in User Interface Errors

    【讨论】:

      【解决方案2】:

      功能区 XML 代码在这里,

      <ribbon>
          <tabs>
            <tab idMso="TabReadMessage">
              <group id="grpMessageRibbon" Label="My Group">
                <button id="btnTest" Label="My Button" size="large" />
              </group>
            </tab>
          </tabs>    
        </ribbon>
      

      基于其功能区 ID 加载功能区 XML。

        public string GetCustomUI(string ribbonID)
              {
                  string ribbonXML = String.Empty;
      
                  if (ribbonID == "Microsoft.Outlook.Report")
                  {
                      ribbonXML = GetResourceText("MicrosoftOutlookReport.xml");
                  }
      
                  return ribbonXML;
              }
      

      谢谢

      【讨论】:

        猜你喜欢
        • 2015-04-15
        • 1970-01-01
        • 2020-07-22
        • 1970-01-01
        • 1970-01-01
        • 2013-05-19
        • 1970-01-01
        • 1970-01-01
        • 2010-12-24
        相关资源
        最近更新 更多