Reputation: 47804
How do I add a new tab, like for example next to the "View" tab, I need a tab "Custom" and I would like to add my controls here.
I am using Visual studio 2013, and project type Outlook 2013 addin, I am new to this outlook addin/plugin development.
I tried something with the below code, which automatically added a new tab called "Add-Ins" and my test button got added there, instead I would like to create a new tab.
Office.CommandBar myCommandBar = this.Application.ActiveExplorer().CommandBars.Add("custom", Office.MsoBarPosition.msoBarFloating, false, true);
myCommandBar.Visible = true;
Office.CommandBarControl cmdBarControl2 = myCommandBar.Controls.Add(Office.MsoControlType.msoControlButton, 1, "", Missing.Value, true);
cmdBarControl2.Visible = true;
cmdBarControl2.Height = 200;
cmdBarControl2.Caption = "My Test button";
Upvotes: 1
Views: 4128
Reputation: 49455
Command Bars were deprecated with Outlook 2010 and not used any longer. You need to use the Ribbon UI (aka Fluent UI) to customize the ribbon in Outlook. VSTO provides two ways for creating a custom ribbon UI:
Also you can read more about the Ribbon Ui controls in the following series of articles in MSDN:
Upvotes: 3
Reputation: 1028
Though you can add ribbons directly using C#, I would highly recommend that you generate ribbons using VS13's built-in designer tools. Begin with generating an Office Add-in (Templates > Visual C# > Office Add-ins -> Outlook 2013 Add-in). Once you have an Add-in project, right click it and select Add -> New item -> Ribbon (Visual Designer). It will then generate a ribbon and the necessary code to initialize it. To answer your question directly, have a look at InitializeComponent() in YourRibbonName.Designer.cs to see how it hooks itself up to the collection of ribbons. Be careful not to alter the code (unless you're quite confident you know what you're doing).
Upvotes: 3