我在VS2017中编写了一个outlook外接程序。当选择一个或多个日历事件时,我需要一个上下文菜单。当使用以下XML选择单个日历事件时,我可以看到上下文菜单:
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui" loadImage="GetImage">
<contextMenus>
<contextMenu idMso="ContextMenuCalendarItem">
<button id="MyContextMenuCalendarItem"
label="Copy To Google Calendar"
image="Google_Calendar_Logo.png"
onAction="CopyToGoogleCalendar_Click"/>
</contextMenu>
</contextMenus>
</customUI>
如果我使用idMso&#34; ContextMenuMultipleItems&#34;,当选择任何类型(电子邮件,日历等)的多个时,将出现上下文菜单。对于选择了多个日历事件的上下文菜单,我无法找出正确的idMso。
非常感谢任何帮助。
答案 0 :(得分:0)
事实证明,使用“ContextMenuMultipleItems”idMso可以使用添加的“getVisible”方法。我的XML现在看起来像:
<?xml version="1.0" encoding="utf-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui" loadImage="GetImage">
<contextMenus>
<contextMenu idMso="ContextMenuCalendarItem">
<button id="MyContextMenuCalendarItem"
label="Copy To Google Calendar"
image="Google_Calendar_Logo.png"
onAction="CopyToGoogleCalendar_Click"/>
</contextMenu>
<contextMenu idMso="ContextMenuMultipleItems">
<button id="MyContextMenuMultipleItems"
label="Copy To Google Calendar"
image="Google_Calendar_Logo.png"
getVisible="ContextMenuMultipleItems_IsVisible"
onAction="CopyToGoogleCalendar_Click"/>
</contextMenu>
</contextMenus>
</customUI>
和ContextMenuMultipleItems_IsVisible看起来像:
public bool ContextMenuMultipleItems_IsVisible(Office.IRibbonControl control)
{
if (control.Context is Outlook.Selection)
{
Outlook.Selection selection = control.Context as Outlook.Selection;
if (selection[1] is Outlook.AppointmentItem)
return true;
}
return false;
}