none
2007 & 2013 - Common Code to Create Dropdown Menu RRS feed

  • Question

  • Hi All,

    I have an existing VSTO Outlook Add-in that loads and works with both 2007 and 2013 versions of Outlook. The Add-in dynamically creates a Dropdown menu on startup and then remove it when Outlook is closed.

    Outlook 2007 - this works fine and the menu is created in the highlighted space below

    Outlook 2013 - this does not create the menu where I want it, instead the menu is placed within the "ADD-INS" ribbon

    Ideally I want the menu to be placed in the highlighted area below:


    Question
    How can I implement some logic to commonly create the menu in the main ribbon for both Outlook 2007 and 2013 version?

    Thanks

     

    Tuesday, December 22, 2015 10:43 AM

Answers

All replies

  • Hello,

    The Explorer window in Outlook 2007 still uses command bars while Inspectors got the Ribbon UI. Starting from Outlook 2010 the Ribbon UI (aka Fluent UI) is used everywhere. So, you need to detect the currently installed Outlook version at runtime and use command bars in case of Outlook 2007 for explorers. For later Outlook versions you need to use the Ribbon UI.

    VSTO provides the following ways for creating a custom ribbon tab (as shown on the screenshot):

    1. Walkthrough: Creating a Custom Tab by Using the Ribbon Designer

    2. Walkthrough: Creating a Custom Tab by Using Ribbon XML

    You can read more about the Fluent UI in the following series of articles:

    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)

    Tuesday, December 22, 2015 10:53 AM
  • Hi Eugene,

    Do you know if I can use C# code instead to achieve what I want in Outlook 2013?

    I do not really want to use Ribbon XML etc

    Tuesday, December 22, 2015 11:19 AM
  • Both approaches can be used in C#. You can use the ribbon designer if you don't want to delve into the Ribbon XML markup. See Walkthrough: Creating a Custom Tab by Using the Ribbon Designer for more information.
    Tuesday, December 22, 2015 2:07 PM
  • >>>Do you know if I can use C# code instead to achieve what I want in Outlook 2013?

    I do not really want to use Ribbon XML etc<<<

    Eugene is right, you could use use the ribbon designer, you could follow these steps:

    1.On the Project menu, choose Add New Item.

    2.In the Add New Item dialog box, select Ribbon (Visual Designer).

    3.Change the name of the new ribbon to MyRibbon, and choose Add.

    4.In the Ribbon Designer, choose the default tab.

    5.In the Properties window, expand the ControlId property, and then set the ControlIdType property to Custom.

    6.In the Ribbon Designer, choose MyRibbon, then in the Properties window, set the RibbonType property to Microsoft.Outlook.Explorer

    Wednesday, December 23, 2015 7:24 AM
  • The deprecated Command Bar model allowed for UI elements to be created exclusively through code.

    If the question is whether a new Tab containing the add-in's controls can be created  by only using C# code without providing Ribbon XML or using the Ribbon Designer then the answer is no, it can't be done.

    Wednesday, December 23, 2015 11:49 AM
  • I do not want to create a TAB, rather I want a Dropdown menu created using C# when the Add-in Starts up.

    I have this working currently using Outlook 2007, however when the same add-in is loaded in 2013, it just puts the Dropdown menu within the ADD-INN Ribbon.

    The ideal scenario using C# would be,

    1. Check which version of Outlook is running

    2. Execute C# code to create a dropdown menu with the desired menu items

    Do you know if this is possible?

    Monday, January 4, 2016 9:30 AM
  • > 2. Execute C# code to create a dropdown menu with the desired menu items

    The Fluent UI doesn't provide any API for creating controls at runtime. The UI is static from its birth. You can use callbacks for returning a Ribbon XML markup instead.

    In case if you want to add your controls to the built-in tab, see How to: Customize a Built-in Tab .

    If you need to customize any context menu in Outlook 2010 and later, see Customizing Context Menus in Office 2010 . Also take a look at the Extending the User Interface in Outlook 2010 article.

    • Marked as answer by David_JunFeng Monday, January 11, 2016 3:06 PM
    Monday, January 4, 2016 9:48 AM
  • I do not want to create a TAB, rather I want a Dropdown menu created using C# when the Add-in Starts up.

    I have this working currently using Outlook 2007, however when the same add-in is loaded in 2013, it just puts the Dropdown menu within the ADD-INN Ribbon.

    The ideal scenario using C# would be,

    1. Check which version of Outlook is running

    2. Execute C# code to create a dropdown menu with the desired menu items

    Do you know if this is possible?

    No, it's not possible.
    Monday, January 4, 2016 10:08 AM