Dec 31, 2013 at 2:43 PM

What is the reason that ActivateTab is not exposed via ExcelDNA IRibbonUI?

If I add code my self to:
public interface IRibbonUI

void ActivateTab([In, MarshalAs(UnmanagedType.BStr)] string ControlID);
I get:
System.ArgumentException occurred
Message=Value does not fall within the expected range.

  1. How do I activate desired ribbon tab using Excel DNA ?
  2. I need this only because after I add ListObject (Table) to collection it activates "Design" tab in ribbon, which is undesirable.
Windows 7 x64, Excel 2010 32bit

Jan 2, 2014 at 9:27 AM
Hi Arnas,

ActiveTab is not included in the Excel-DNA copy of the interface, since it was not there in Excel 2007 when I did this.

Your plan would work, but the DispId should be 4.

The extended interface now looks like this (not sure whether you should leave the InterCall flags):
    [Guid("000C03A7-0000-0000-C000-000000000046"), TypeLibType(4160)]
    public interface IRibbonUI
        void Invalidate();
        void InvalidateControl([MarshalAs(UnmanagedType.BStr)] [In] string ControlID);
        void InvalidateControlMso([MarshalAs(UnmanagedType.BStr)] [In] string ControlID);
        void ActivateTab([MarshalAs(UnmanagedType.BStr)] [In] string ControlID);
        void ActivateTabMso([MarshalAs(UnmanagedType.BStr)] [In] string ControlID);
        void ActivateTabQ([MarshalAs(UnmanagedType.BStr)] [In] string ControlID, [MarshalAs(UnmanagedType.BStr)] [In] string Namespace);
Jan 2, 2014 at 11:58 AM
Thanks. Works well.
Do you plan to add it to stable version any time soon?
Jan 2, 2014 at 12:07 PM
Hi Arnas,

Thanks for the feedback.

It will be updated in the next check-in.
To be clear: you need not update the interface definition in the Excel-DNA code - if you use the full interface defined in your own library and it will also work fine with the current Excel-DNA release.

Jan 3, 2014 at 12:44 PM
Thanks for hint. Created my own copy of interface and it works fine.