show outlook ribbon near appointmentTab

南笙酒味 提交于 2019-12-25 06:23:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!