如何在 Outlook 的报告选项卡中添加自定义功能区按钮
How to add custom ribbon button in Report tab of outlook
我想在 Outlook 的 "Report" 选项卡中添加我的自定义功能区按钮。我可以在 Outlook 的 "Home" 选项卡中添加功能区按钮。我在此处附上了要添加自定义功能区按钮的图像。
谢谢
屏幕截图中显示的内置选项卡的idMso是TabReadMessage
。您只需要在 GetCustomUI
回调中 return 适当的功能区 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;
}
请注意,有时您需要 return XML 标记作为参数传递的不同 ribbonID
值。在这种情况下,您将调用 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(又名功能区 UI)的更多信息:
- Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
- Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
- Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
请记住,默认情况下,如果 VSTO 加载项尝试操作 Microsoft Office 用户界面 (UI) 但失败,则不会显示任何错误消息。但是,您可以将 Microsoft Office 应用程序配置为显示与 UI 相关的错误消息。您可以使用这些消息来帮助确定自定义功能区未出现的原因,或者显示功能区但未显示控件的原因。有关详细信息,请参阅 How to: Show Add-in User Interface Errors。
功能区XML代码在这里,
<ribbon>
<tabs>
<tab idMso="TabReadMessage">
<group id="grpMessageRibbon" Label="My Group">
<button id="btnTest" Label="My Button" size="large" />
</group>
</tab>
</tabs>
</ribbon>
功能区 XML 根据其功能区 ID 加载。
public string GetCustomUI(string ribbonID)
{
string ribbonXML = String.Empty;
if (ribbonID == "Microsoft.Outlook.Report")
{
ribbonXML = GetResourceText("MicrosoftOutlookReport.xml");
}
return ribbonXML;
}
谢谢
我想在 Outlook 的 "Report" 选项卡中添加我的自定义功能区按钮。我可以在 Outlook 的 "Home" 选项卡中添加功能区按钮。我在此处附上了要添加自定义功能区按钮的图像。
谢谢
屏幕截图中显示的内置选项卡的idMso是TabReadMessage
。您只需要在 GetCustomUI
回调中 return 适当的功能区 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;
}
请注意,有时您需要 return XML 标记作为参数传递的不同 ribbonID
值。在这种情况下,您将调用 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(又名功能区 UI)的更多信息:
- Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
- Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
- Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
请记住,默认情况下,如果 VSTO 加载项尝试操作 Microsoft Office 用户界面 (UI) 但失败,则不会显示任何错误消息。但是,您可以将 Microsoft Office 应用程序配置为显示与 UI 相关的错误消息。您可以使用这些消息来帮助确定自定义功能区未出现的原因,或者显示功能区但未显示控件的原因。有关详细信息,请参阅 How to: Show Add-in User Interface Errors。
功能区XML代码在这里,
<ribbon>
<tabs>
<tab idMso="TabReadMessage">
<group id="grpMessageRibbon" Label="My Group">
<button id="btnTest" Label="My Button" size="large" />
</group>
</tab>
</tabs>
</ribbon>
功能区 XML 根据其功能区 ID 加载。
public string GetCustomUI(string ribbonID)
{
string ribbonXML = String.Empty;
if (ribbonID == "Microsoft.Outlook.Report")
{
ribbonXML = GetResourceText("MicrosoftOutlookReport.xml");
}
return ribbonXML;
}
谢谢