Search code examples
c#vstoexcel-addinscustomtaskpane

C# VSTO Excel Addins: How can I access Ribbons Controls from the Addins ThisAddIn_Startup?


I'm designing an Excel Addins with Ribbons like this:

enter image description here

  • The Ribbon Name is Ribbon1
  • The Tab Name is Tab1
  • The ToggleButton name is tglShowNavigation

What I need is:

From the ThisAddIn.cs, in the ThisAddIn_Startup void, I would like to be able to Affect/Change the ToggleButton tglShowNavigation's Label.

I tried the following but cannot see any control from this:

enter image description here

Where and how could I access the Controls on my Ribbon from the ThisAddIn_Startup please?

NB: I don't want to call a global function from the Ribbon, but just want to be able to access them directly.

Thank you in advanced for you precious help!


Solution

  • You can get access to the control by using

    Globals.Ribbons.Ribbon1.tglShowNavigation
    

    Make sure you've changed the modifier of the button to something you can reach, one example could be "Internal".

    enter image description here