show outlook ribbon near appointmentTab

2019-09-01 07:09发布

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;
    }

2条回答
Summer. ? 凉城
2楼-- · 2019-09-01 07:19

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:

查看更多
姐就是有狂的资本
3楼-- · 2019-09-01 07:30

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");
    }
查看更多
登录 后发表回答