Patrick Patrick - 1 year ago 270
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?

Answer Source

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");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download