简体   繁体   English

如何在Outlook的“报告”选项卡中添加自定义功能区按钮

[英]How to add custom ribbon button in Report tab of outlook

I want to add my custom ribbon button in the "Report" tab of Outlook. 我想在Outlook的“报告”选项卡中添加我的自定义功能区按钮。 I am able to add a ribbon button in "Home" Tab of Outlook. 我可以在Outlook的“主页”选项卡中添加功能区按钮。 Here I have attached the image where I want to add my custom ribbon button. 在这里,我已将图像附加到要添加自定义功能区按钮的位置。

在此处输入图片说明

Thanks 谢谢

Ribbon XML Code is here, 功能区XML代码在这里,

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

Ribbon XML load based on it's ribbon id. 基于功能区ID的功能区XML负载。

  public string GetCustomUI(string ribbonID)
        {
            string ribbonXML = String.Empty;

            if (ribbonID == "Microsoft.Outlook.Report")
            {
                ribbonXML = GetResourceText("MicrosoftOutlookReport.xml");
            }

            return ribbonXML;
        }

Thanks 谢谢

The idMso of the built-in tab shown on the screenshot is TabReadMessage . 在屏幕截图中显示的内置选项卡的idMsoTabReadMessage You just need to return an appropriate ribbon XML markup in the GetCustomUI callback. 您只需要在GetCustomUI回调中返回适当的功能区XML标记。

Microsoft Office applications call the GetCustomUI method to obtain an XML string that defines the user interface of your custom Ribbon. 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; 
 }

Note, sometimes you need to return the XML markup for different ribbonID values passed as an argument. 注意,有时您需要返回作为参数传递的不同ribbonID值的XML标记。 In that case you will get the onLoad callback invoked (for inspectors too). 在这种情况下,您将调用onLoad回调(也适用于检查器)。

    public string GetCustomUI(string ribbonID)
    {
        string ribbonXML = String.Empty;

        if (ribbonID == "Microsoft.Outlook.Mail.Read")
        {
            ribbonXML = GetResourceText("Trin_RibbonOutlookBasic.Ribbon1.xml");
        }

        return ribbonXML;
    }

See Customizing a Ribbon for Outlook for more information. 有关更多信息,请参见自定义Outlook功能区

You can read more about the Fluent UI (aka Ribbon UI) in the following series of articles in MSDN: 您可以在MSDN的以下系列文章中阅读有关Fluent UI(又称为Ribbon UI)的更多信息:

Please remember that by default, if an VSTO add-in attempts to manipulate the Microsoft Office user interface (UI) and fails, no error message is displayed. 请记住,默认情况下,如果VSTO加载项尝试操作Microsoft Office用户界面(UI)失败,则不会显示任何错误消息。 However, you can configure Microsoft Office applications to display messages for errors that relate to the UI. 但是,您可以配置Microsoft Office应用程序以显示有关UI的错误消息。 You can use these messages to help determine why a custom Ribbon does not appear, or why a Ribbon appears but no controls appear. 您可以使用这些消息来帮助确定为什么不显示自定义功能区,或者为什么显示功能区但不显示控件。 See How to: Show Add-in User Interface Errors for more information. 有关更多信息,请参见如何:显示外接程序用户界面错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM