0
votes

I the designer (not XML) to define my custom ribbon like this: Basically I define one Group and add it to two different tabs which are assigned to two different OfficeIds (TabAppointment and TabCalendar). Unfortunately the Ribbon only shows up on the calendar not on the appointment. Although if I remove tab2 it shows up on appointment. So I conclude that there is only one tab allows? How can I accomplish to reuse my group in two tabs / OfficeIds?

namespace OutlookAddIn4
{
    partial class MyAddInDo : Microsoft.Office.Tools.Ribbon.RibbonBase
    {
        /// <summary>
        /// Erforderliche Designervariable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        public MyAddInDo()
            : base(Globals.Factory.GetRibbonFactory())
        {
            InitializeComponent();
        }

        /// <summary> 
        /// Verwendete Ressourcen bereinigen.
        /// </summary>
        /// <param name="disposing">"true", wenn verwaltete Ressourcen gelöscht werden sollen, andernfalls "false".</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Vom Komponenten-Designer generierter Code

        /// <summary>
        /// Erforderliche Methode für Designerunterstützung -
        /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
        /// </summary>
        private void InitializeComponent()
        {
            this.tab1 = this.Factory.CreateRibbonTab();
            this.group1 = this.Factory.CreateRibbonGroup();
            this.btnAddMyAddInDo = this.Factory.CreateRibbonButton();
            this.btnViewInMyAddInDo = this.Factory.CreateRibbonButton();
            this.btnRemoveFromMyAddInDo = this.Factory.CreateRibbonButton();
            this.btnSettings = this.Factory.CreateRibbonButton();
            this.tab2 = this.Factory.CreateRibbonTab();
            this.tab1.SuspendLayout();
            this.group1.SuspendLayout();
            this.tab2.SuspendLayout();
            this.SuspendLayout();
            // 
            // tab1
            // 
            this.tab1.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
            this.tab1.ControlId.OfficeId = "TabAppointment";
            this.tab1.Groups.Add(this.group1);
            this.tab1.Label = "TabAppointment";
            this.tab1.Name = "tab1";
            // 
            // group1
            // 
            this.group1.Items.Add(this.btnAddMyAddInDo);
            this.group1.Items.Add(this.btnViewInMyAddInDo);
            this.group1.Items.Add(this.btnRemoveFromMyAddInDo);
            this.group1.Items.Add(this.btnSettings);
            this.group1.Label = "MyAddInDo";
            this.group1.Name = "group1";
            this.group1.Position = this.Factory.RibbonPosition.AfterOfficeId("GroupActions");
            // 
            // btnAddMyAddInDo
            // 
            this.btnAddMyAddInDo.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
            this.btnAddMyAddInDo.Image = global::OutlookAddIn4.Properties.Resources.do_48x48;
            this.btnAddMyAddInDo.Label = "Add Minutes";
            this.btnAddMyAddInDo.Name = "btnAddMyAddInDo";
            this.btnAddMyAddInDo.ShowImage = true;
            this.btnAddMyAddInDo.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnAddMyAddInDo_Click);
            // 
            // btnViewInMyAddInDo
            // 
            this.btnViewInMyAddInDo.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
            this.btnViewInMyAddInDo.Image = global::OutlookAddIn4.Properties.Resources.do_48x48;
            this.btnViewInMyAddInDo.Label = "View Minutes";
            this.btnViewInMyAddInDo.Name = "btnViewInMyAddInDo";
            this.btnViewInMyAddInDo.ShowImage = true;
            this.btnViewInMyAddInDo.Visible = false;
            this.btnViewInMyAddInDo.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.ViewInMyAddInDo_Click);
            // 
            // btnRemoveFromMyAddInDo
            // 
            this.btnRemoveFromMyAddInDo.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
            this.btnRemoveFromMyAddInDo.Image = global::OutlookAddIn4.Properties.Resources.do_48x48;
            this.btnRemoveFromMyAddInDo.Label = "Remove Minutes";
            this.btnRemoveFromMyAddInDo.Name = "btnRemoveFromMyAddInDo";
            this.btnRemoveFromMyAddInDo.ShowImage = true;
            this.btnRemoveFromMyAddInDo.Visible = false;
            this.btnRemoveFromMyAddInDo.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.RemoveFromMyAddInDo_Click);
            // 
            // btnSettings
            // 
            this.btnSettings.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
            this.btnSettings.Image = global::OutlookAddIn4.Properties.Resources.do_48x48;
            this.btnSettings.Label = "Settings";
            this.btnSettings.Name = "btnSettings";
            this.btnSettings.ShowImage = true;
            this.btnSettings.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.Settings_Click);
            // 
            // tab2
            // 

            this.tab2.Label = "tab2";
            this.tab2.Name = "tab2";
            this.tab2.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
            this.tab2.ControlId.OfficeId = "TabCalendar";
            this.tab2.Groups.Add(this.group1);
            this.tab2.Label = "TabSettings";            


            // 
            // MyAddInDo
            // 
            this.Name = "MyAddInDo";
            this.RibbonType = "Microsoft.Outlook.Appointment, Microsoft.Outlook.Explorer";
            this.Tabs.Add(this.tab2);
            this.Tabs.Add(this.tab1);
            this.Load += new Microsoft.Office.Tools.Ribbon.RibbonUIEventHandler(this.MyAddInDo_Load);
            this.tab1.ResumeLayout(false);
            this.tab1.PerformLayout();
            this.tab2.ResumeLayout(false);
            this.tab2.PerformLayout();
            this.group1.ResumeLayout(false);
            this.group1.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        internal Microsoft.Office.Tools.Ribbon.RibbonTab tab1;
        internal Microsoft.Office.Tools.Ribbon.RibbonGroup group1;
        internal Microsoft.Office.Tools.Ribbon.RibbonButton btnAddMyAddInDo;
        internal Microsoft.Office.Tools.Ribbon.RibbonButton btnViewInMyAddInDo;
        internal Microsoft.Office.Tools.Ribbon.RibbonButton btnRemoveFromMyAddInDo;
        internal Microsoft.Office.Tools.Ribbon.RibbonButton btnSettings;
        internal SettingsForm settingsForm;
        internal Microsoft.Office.Tools.Ribbon.RibbonTab tab2;
    }

    partial class ThisRibbonCollection
    {
        internal MyAddInDo MyAddInDo
        {
            get { return this.GetRibbon<MyAddInDo>(); }
        }
    }
}
1

1 Answers

0
votes

Do you get any Ribbon UI errors?

By default, if an add-in attempts to manipulate the Microsoft Office user interface (UI) and fails, no error message is displayed. However, you can configure Microsoft Office applications to display messages for errors that relate to the UI. You can use these messages to help determine why a custom ribbon does not appear, or why a ribbon appears but no controls appear.

To show VSTO Add-in user interface errors

  1. Start the application.
  2. Click the File tab.
  3. Click Options.
  4. In the categories pane, click Advanced.
  5. In the details pane, select Show VSTO Add-in user interface errors, and then click OK.

For Outlook, the Show VSTO Add-in user interface errors checkbox is located in the Developer section of the details pane. For other applications, the checkbox is located in the General section of the details pane. Read more about that in the How to: Show Add-in user interface errors article.


You need to define a separate group of controls for each tab.