CodeMinion
CodeMinion

Reputation: 653

CommandBars in outlook 2010

so I've noticed that CommandBars appear in tabAddIns in outlook 2010 by default. Is there any way I can get them to appear in my custom ribbon tab instead?

If it is impossible or very challenging, I welcome suggestions for easier ways to achieve something similar.

Upvotes: 1

Views: 2354

Answers (3)

Jake Ginnivan
Jake Ginnivan

Reputation: 2142

If you require Office 2007/2003 support (which I assume is the reason you have the command bar's) then you ideally need to check the MajorVersion of the office interop dll that is running.

Then you can do soemthing like:

string majorVersionString = Globals.ThisAddIn.Application.Version.Split(new char[] { '.' })[0];
int majorVersion = Convert.ToInt32(majorVersionString);
if (majorVersion < 14)
{
    //Register CommandBar
}

Then also create a ribbon targeting the OutlookExplorer ribbon. Because only office 2010 will request that ribbon type, then it will only work for Office 2010.

See http://msdn.microsoft.com/en-us/library/bb398246.aspx for how to create ribbon xml ribbons. The ribbon ID you are after is Microsoft.Outlook.Explorer. More information about extending the Outlook explorer ribbon can be found at http://msdn.microsoft.com/en-us/library/ee692172.aspx#OfficeOLExtendingUI_Explorer

EDIT: More information about multitargeting multiple versions of Office is available at http://blogs.msdn.com/b/vsto/archive/2010/06/04/creating-an-add-in-for-office-2007-and-office-2010-that-quot-lights-up-quot-on-office-2010-mclean-schofield.aspx

Upvotes: 1

DarinH
DarinH

Reputation: 4879

You can't control where CommandBar buttons go. That's a "compatibility support" feature of Outlook (and the rest of Office actually) intended only to allow older addins to continue to run and have they're buttons accessible. If you're targeting 2010, you should generally avoid the old CommandBar* objects, and use the ribbon customization instead.

Upvotes: 1

Mike Cales
Mike Cales

Reputation: 101

You can create a custom ribbon tab with the Ribbon Designer and move your CommandBar items to be ribbon buttons.

An decent example can be found http://msdn.microsoft.com/en-us/library/bb386104.aspx

Upvotes: 2

Related Questions