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

六月ゝ 毕业季﹏ 提交于 2021-02-08 05:22:10

问题


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

  • 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:

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!


回答1:


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".



来源:https://stackoverflow.com/questions/61057803/c-sharp-vsto-excel-addins-how-can-i-access-ribbons-controls-from-the-addins-thi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!