Patrick Patrick - 6 months ago 105
C# Question

VSTO Word activate ribbon tab

I have the following ribbon.xml in my word vsto add-in:

<tab id="TabLetters" getVisible="IsLettersTabVisible" label="Letters">
<group id="LettersGroup" label="Letters">
<toggleButton id="NewWithTemplate"
label="New using template Controls"
onAction="NewTemplated" />

And the following code behind the click event:

public void NewTemplated(Office.IRibbonControl control, bool value)

var doc = Globals.ThisAddIn.Application.Documents.Add(Template: @"LETTER_V2.dotx", Visible: true);


I would have expected this to result in a new window with my ribbon tab opened, however it just remains the HOME tab that is visible/current. How do I make it happen that my tab is the one that is visible?


Here are two ways you can use to set the active tab:

TabLetters.RibbonUI.ActivateTab("TabLetters"); or

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