简体   繁体   中英

How to add a new tab in Outlook. Outlook addin/plugin development using Visual Studio 2013

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";

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:

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

Also you can read more about the Ribbon Ui controls in the following series of articles in MSDN:

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM