none
Two Ribbon in a project RRS feed

  • Question

  • Hi,

    I've two problem in outllook addins application.

    First Problem:

    1. I used two ribbon and want to display one ribbon at the outlook explorer and another one should be display at mail.compose..In the explorer dispaly that ribbon but when user click new mail it does not display another ribbon. Mentioned that in the explorer ribbon have some static checkbox control but in other ribbon have dynamaics checkbox control. Mentioned that i override the ribbon in the thisaddins. I checked the xml of this ribbon but it's does not read the ribbon_load method. Så it does not works. In the load method, according to no of the items (from database) it will create the control.

    Second Problem:

    2. If i uesd one riboon and want to display in the explorer and mail.compose and with is ribbon i used some dynamics control.problem is that in the explore it does not shown the control but when user click the new mail it shows the controllen. 

    it's read the ribbon_load method as well. Så it does works. In the load method, according to no of the items (from database) it will create the control.

    I used VS 2010 Outlook addins

    Regards

    /Shahin

    Thursday, March 26, 2015 11:39 AM

Answers

All replies

  • Hello Shahin,

    It is not clear whether you use the Ribbon Designer or Ribbon XML for the custom UI.

    1. You need to return an appropriate Ribbon markup depending on the context passed to the GetCustomUI method. For example, if you are using the Ribbon (XML) item, check the value of the ribbonID parameter in the GetCustomUI method and return the appropriate ribbon.:

    public string GetCustomUI(string ribbonID)
    {
        string ribbonXML = String.Empty;
    
        if (ribbonID == "Microsoft.Outlook.Mail.Compose")
        {
            ribbonXML = GetResourceText("Trin_RibbonOutlookBasic.Ribbon1.xml");
        }
    
        return ribbonXML;
    }

    See Customizing a Ribbon for Outlook for more information.

    If you use the Ribbon Designer you need to choose the desired contexts using the RibbonType property.

    2. The Ribbon UI is a static thing. You can't create controls on the fly. Read more about the Fluent UI in the following series of articles in MSDN:

    1. Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

    2. Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

    3. Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

    Finally, I'd recommend checking for UI errors every time. See How to: Show Add-in User Interface Errors for more information. The Ribbon tab may hidden automatically if your Ribbon markup contains an error.

    Thursday, March 26, 2015 12:42 PM
  • Hi,

    Thanks for your reply. I used Ribbon Designer.  and Check error to enable to show Add ins ..... that. It does not showed any error. But still the other ribbon has not been shown.

    Not only of that if i used only one ribbon which have dynamic control then it has been shown when the user click the new mail/reply that means that the Ribbon has no problem. But the is that case it does not showed the control in the explorer.

    Actullay I want to develop a ribbon which is have dynamic control like checkbox(no of control which is comes from database) and that will display in both explorer and mail.compose. 

    If this Ribbon works in both case så i need not use two ribbon. but still two ribbon concept does not works.

    regards

    /Shahin

    Thursday, March 26, 2015 3:53 PM
  • Shahin,

    I used Ribbon Designer.  and Check error to enable to show Add ins ..... that. It does not showed any error. But still the other ribbon has not been shown.

    Did you check out the RibbonType property shown on the screenshot above? What values do you have set?

    Actullay I want to develop a ribbon which is have dynamic control like checkbox(no of control which is comes from database) and that will display in both explorer and mail.compose. 

    You need to use the Ribbon XML to compose the markup according to the database entries on the fly. And specify callbacks as attributes. Thus, you can update the UI at runtime. 

    Read more about the Fluent UI (aka Ribbon UI) in the following series of articles in MSDN:

    1. Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

    2. Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

    3. Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

    Thursday, March 26, 2015 5:07 PM
  • Hi,

    Thanks. Yes I uesd RibbonType property as you shown with in the screen shot. But still it does not work.

    Regards

    /Shahin

    Friday, March 27, 2015 8:56 AM
  • What values do you have set?

    Do you get any UI errors after changing the RibbonType property and rebuilding the add-in?

    Friday, March 27, 2015 11:16 AM
  • Hi,

    I did.I used mail.compose and mail.read what you mention before. I think check my code:

    public bool myCondition = true;
    
    protected override Office.IRibbonExtensibility CreateRibbonExtensibilityObject()
            
            {
                if (myCondition == true)
                {
                    Ribbon_Signature tempRibbon = new Ribbon_Signature();
                    tempRibbon.MyOutlookTab.ControlId.ControlIdType =
                        Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
                    tempRibbon.MyOutlookTab.ControlId.OfficeId = "TabAddIns";
                    return Globals.Factory.GetRibbonFactory().CreateRibbonManager(
                        new Microsoft.Office.Tools.Ribbon.IRibbonExtension[] { tempRibbon });
                }
                else
                {
    
    
    
                    Ribbon_Signature_DynamicKontrol tempRibbon = new Ribbon_Signature_DynamicKontrol();
                    tempRibbon.Tabstest.ControlId.ControlIdType =
                        Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
                    tempRibbon.Tabstest.ControlId.OfficeId = "TabInföga";
                    return Globals.Factory.GetRibbonFactory().CreateRibbonManager(
                                        new Microsoft.Office.Tools.Ribbon.IRibbonExtension[] { tempRibbon });
                }
    
    
            }
    
    
    private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                inspectors = this.Application.Inspectors;
                inspectors.NewInspector +=new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
    
    
                currentExplorer = this.Application.ActiveExplorer();
                currentExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorer_Event);
                
            }
    
    
    void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
            {
    
    
                myCondition = false;
    
                CreateRibbonExtensibilityObject();
    
            }
    

    (I call CreateRibbonExtensibilityObject because of if the user click like new mail or reply)


    .Since I told you if i used only one ribbon which have dynamic control (My second ribbon).. Then works if user click new mail.So there is no UI error. I rebuilded as well.

    Regards

    /Shahin


    Friday, March 27, 2015 1:30 PM
  • Shahin,

    I used mail.compose and mail.read 

    But I don't see that you chose the Microsoft.Outlook.Explorer value. You need to set the correct values for the RibbonType property if you want to see controls in the Explorer window.

    Friday, March 27, 2015 1:53 PM
  • Hi,

    I did before like Microsoft.Outlook.explorer,Microsoft.Outlook.mail.composer and Microsoft.Outlook..mail.read and that didn't work and Now checked again but still same problem.

    Anything more?

    Regards

    /Shahin

    Friday, March 27, 2015 2:10 PM
  • There is no need to call the CreateRibbonExtensibilityObject method in the NewInspector event handler. It is called by Office.

    It looks like the issue comes from your code. Try to reproduce the issue with a newly create add-in project. You may find the following articles helpful:

    Walkthrough: Creating a Custom Tab by Using Ribbon XML

    Walkthrough: Creating a Custom Tab by Using the Ribbon Designer 

    Friday, March 27, 2015 2:15 PM
  • Hi,

    okej. I seem that i thought.. but what i think how it will call CreateRibbonExtensibilityObject method when the user click new mail/reply..

    I will do again newly.Do you think anything else that why office does not call CreateRibbonExtensibilityObject method?

    Regards

    /S

    Friday, March 27, 2015 2:31 PM
  • As I said, Office applications calls the overloaded method (actually VSTO does, Office calls the GetCustomUI method). There is no need to call it manually.

    I suppose the cause of the issue is your code in the overloaded method. Try use the code/markup described in the articles listed above instead.

    Friday, March 27, 2015 2:34 PM