none
Outlook Ribbon customization RRS feed

  • Question

  • Hello everybody!

    I firstly wanted to ask if there's any really simple example on customizing Outlook 2007 Ribbon of the Outlook Task item?

     

    I'm just stuck with trying to understand how it works, although I've read appropriate chapters from Professional Outlok 2007 Programming book :/ .....

     

    Presicely, what I need to do is to:

    1) Modify the action of the "Mark Complete" button in Manage Task group

    2) Remove other buttons from this group(or disable them if removalk is impossible)

    3) Add my own buttons and probably other controls here(if possible)

     

    I'll appreciate any kind of assistance, thanks in advance.

     

     

    Monday, August 18, 2008 11:12 AM

Answers

  • Hi ,

     As I know you couldn't achieve that by modiy the built-in Ribbon buttons.But there's a alternative way.I'll show you the idea below:

     

    1)Hide the Manage Task group

    2)Build your own group by using the XML.

    3)Add your own Button into the group to hook user's action.

    4)perform you own action when click event fires

     

    Before I start the sample I'd like you to introduce you some really useful articles about how to customize the Ribbon. These articles cover almost everything you need.

    http://msdn.microsoft.com/en-us/aa338202.aspx

    http://msdn.microsoft.com/en-us/aa338199.aspx

    http://msdn.microsoft.com/en-us/aa722523.aspx

     

    As you didn't mention the version of your Visual Studio,so I'll start with my Vistual Studio 2008:

     

    Firstly , go the Solution Explorer,Right Click at your Add-In project ,select Add-New Item...,pick up the "Ribbon(XML)" in the dialog.

     

    Then,you'll find two new files Ribbon1.cs &Ribbon.xml in your Solution Explorer.

     

    Open the Ribbon1.xml replace the content with the following code : 

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="
    http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
      <ribbon>
        <tabs>
          <tab idMso="TabTask">
           
            <group idMso="GroupManageTask" visible="false">
           
            </group>
            <group id="MyGroup" label="Fake"  insertBeforeMso="GroupTaskOptions">

              <button id="Button1" label="Mask Complete" size="large" onAction="getClicked" imageMso="MarkTaskComplete"  />
                </group >
           
          </tab>
        </tabs>
      </ribbon>
    </customUI>


    idMso is the Id of built-in Ribbon controls ,how to get it I will explan later.

    OnAction gives the method name to callback when the button clicked.

    imageMso make you could use the icon of a specific built-in button.Value is the same as idMso

    If you want to bring the built-in control to your grouop you need to following:

        <button idMso="SendStatusReport"/>

    Next Open the Ribbon1.cs file,modify the GetCustomUI method like this:

     

            public string GetCustomUI(string ribbonID)
            {
                         //Customize the Ribbon just when user open a task window. 

               if (ribbonID == "Microsoft.Outlook.Task")
                    return GetResourceText("OutlookAddIn2.Ribbon1.xml");
                else
                    return "";
     }

     

     

            public void getClicked(Office.IRibbonControl Control)
            {
                 //Put your own code here to perform actions you want.

                

                  Outlook.Application app = Globals.ThisAddIn.Application;

           }

    Finally,Add

            protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
            {
                return new Ribbon1();
            }

    to your ThisAddIn.cs file to active your Ribbon.

     

    Download from the following link to get all the idMso value of all controls in Office

    http://www.microsoft.com/downloads/details.aspx?familyid=4329D9E9-4D11-46A5-898D-23E4F331E9AE&displaylang=en

     

    Thanks

    Wednesday, August 20, 2008 9:50 AM

All replies

  • Hi ,

     As I know you couldn't achieve that by modiy the built-in Ribbon buttons.But there's a alternative way.I'll show you the idea below:

     

    1)Hide the Manage Task group

    2)Build your own group by using the XML.

    3)Add your own Button into the group to hook user's action.

    4)perform you own action when click event fires

     

    Before I start the sample I'd like you to introduce you some really useful articles about how to customize the Ribbon. These articles cover almost everything you need.

    http://msdn.microsoft.com/en-us/aa338202.aspx

    http://msdn.microsoft.com/en-us/aa338199.aspx

    http://msdn.microsoft.com/en-us/aa722523.aspx

     

    As you didn't mention the version of your Visual Studio,so I'll start with my Vistual Studio 2008:

     

    Firstly , go the Solution Explorer,Right Click at your Add-In project ,select Add-New Item...,pick up the "Ribbon(XML)" in the dialog.

     

    Then,you'll find two new files Ribbon1.cs &Ribbon.xml in your Solution Explorer.

     

    Open the Ribbon1.xml replace the content with the following code : 

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="
    http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
      <ribbon>
        <tabs>
          <tab idMso="TabTask">
           
            <group idMso="GroupManageTask" visible="false">
           
            </group>
            <group id="MyGroup" label="Fake"  insertBeforeMso="GroupTaskOptions">

              <button id="Button1" label="Mask Complete" size="large" onAction="getClicked" imageMso="MarkTaskComplete"  />
                </group >
           
          </tab>
        </tabs>
      </ribbon>
    </customUI>


    idMso is the Id of built-in Ribbon controls ,how to get it I will explan later.

    OnAction gives the method name to callback when the button clicked.

    imageMso make you could use the icon of a specific built-in button.Value is the same as idMso

    If you want to bring the built-in control to your grouop you need to following:

        <button idMso="SendStatusReport"/>

    Next Open the Ribbon1.cs file,modify the GetCustomUI method like this:

     

            public string GetCustomUI(string ribbonID)
            {
                         //Customize the Ribbon just when user open a task window. 

               if (ribbonID == "Microsoft.Outlook.Task")
                    return GetResourceText("OutlookAddIn2.Ribbon1.xml");
                else
                    return "";
     }

     

     

            public void getClicked(Office.IRibbonControl Control)
            {
                 //Put your own code here to perform actions you want.

                

                  Outlook.Application app = Globals.ThisAddIn.Application;

           }

    Finally,Add

            protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
            {
                return new Ribbon1();
            }

    to your ThisAddIn.cs file to active your Ribbon.

     

    Download from the following link to get all the idMso value of all controls in Office

    http://www.microsoft.com/downloads/details.aspx?familyid=4329D9E9-4D11-46A5-898D-23E4F331E9AE&displaylang=en

     

    Thanks

    Wednesday, August 20, 2008 9:50 AM
  •  

    Tim Li, thanks a lot! That's a really good explanatory example. Answered.
    Thursday, August 21, 2008 11:04 AM
  • That's a really good!!!!!
    Tuesday, March 16, 2010 10:29 AM