1
votes

I am working on an Excel addin which has a ribbon of its own with some buttons which do some data access/population. One of the buttons/functions imports some data and populates the worksheet. After it populates the sheet, it turns the data into an Excel table using the following code -

   fullRange.Worksheet.ListObjects.AddEx(
    SourceType: Microsoft.Office.Interop.Excel.XlListObjectSourceType.xlSrcRange,
    Source: fullRange,
    XlListObjectHasHeaders: Microsoft.Office.Interop.Excel.XlYesNoGuess.xlYes);

My problem is that, every time the data population in an Excel table format is done, the ribbon highlighted changes to Design->Table Tools and not my addin ribbon.

So my question is... Is there a way to programmatically highlight a ribbon in Excel using VSTO? so I can do that right after populating. Thanks in advance!

1
I usually use VBA, not VSTO. Does VSTO have an IRibbonUI object type? In VBA, you dim an object as IRibbonUI then use the ActivateTab method. - Trashman

1 Answers

1
votes

Two ways to select the correct tab of the ribbon:

TabLetters.RibbonUI.ActivateTab("yourTab"); 

or

Globals.Ribbons.CustomRibbon.Tabs[Your tab id].RibbonUI.ActivateTab("yourTab");