问题
I created new outlook ribbon by ribbonXML
I want to show this Ribbon
1. in Appointment\Meeting window
2. in CalendarItems near 'Appointment' tab , when appointment is selected from the calendar view
I can display the two options but not together in one Ribbon.
"contextualTabs" - displays the tab in calendarItems,
"TabAddins" - displays the tab only in appointment\meeting window according to the C# code
I want this Ribbon will be displayed in both of these cases.How can I do it?
My Code:
<ribbon>
<tabs>
<tab idMso="TabAddIns" label="MyTab">
<group id="group1" label="save">
<button id="btnSaveAs" onAction="btnSaveAs_Click"
imageMso="FileSave"/>
</group>
</tab>
</tabs>
<contextualTabs>
<tabSet idMso="TabSetAppointment">
<tab id="TabAppointment" label="MyTab">
<group id="MyGroup" label="save">
<button id="btnSaveAppAs" onAction="btnSaveAs_Click" label="save"
imageMso="FileSave"/>
</group>
</tab>
</tabSet>
</contextualTabs>
</ribbon>
C#: (cause showing the ribbon only in appointment\meeting window)
public string GetCustomUI(string ribbonID)
{
if(ribbonID=="Microsoft.Outlook.Appointment")
return GetResourceText("OutlookAddIn.Ribbon.xml");
if (ribbonID == "Microsoft.Outlook.MeetingRequest")
return GetResourceText("OutlookAddIn.Ribbon.xml");
return null;
}
回答1:
It looks like you need to return an appropriate Ribbon XML markup for the Explorer ribbon ID value. Try to debug the GetCustomUI
method and see what values are passed.
Read more about the Ribbon UI (aka Fluent UI) in the following articles in MSDN:
- 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)
回答2:
I found the solution.
I put the two options in two separate xml files and repaired getcustomUI
Ribbon.xml:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
<ribbon>
<tabs>
<tab idMso="TabAddIns" label="MyTab">
<group id="group1" label="save">
<button id="btnSaveAs" onAction="btnSaveAs_Click"
imageMso="FileSave"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
CalendarToolsRibbon.xml:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
<ribbon>
<contextualTabs>
<tabSet idMso="TabSetAppointment">
<tab id="TabAppointment" label="MyTab">
<group id="MyGroup" label="save">
<button id="btnSaveAppAs" onAction="btnSaveAs_Click" label="save"
imageMso="FileSave"/>
</group>
</tab>
</tabSet>
</contextualTabs>
</ribbon>
</customUI>
C#:
public string GetCustomUI(string ribbonID)
{
if (ribbonID == "Microsoft.Outlook.Appointment")
return GetResourceText("OutlookAddIn.Ribbon.xml");
if (ribbonID == "Microsoft.Outlook.MeetingRequest.Read")
return GetResourceText("OutlookAddIn.Ribbon.xml");
return GetResourceText("OutlookAddIn.CalendarToolsRibbon.xml");
}
来源:https://stackoverflow.com/questions/32435908/show-outlook-ribbon-near-appointmenttab