简体   繁体   中英

Hide/Unhide Excel Tab Ribbon

I really need help, sorry if this question has been already asked.

I have a addin installed on my computer for Excel, which creates a new Ribbon Tab, named "Forecast". This tab is useful only for a specific file, and for the other Excels I want it to be hidden.

I've been thinking on this a lot, and I came to the conclusion that the tab has to be hidden by default and shown by VBA code on opening of the file and hidden on beforeClose event, but I don't really know how to do this.

If anyone else has a better idea and would like to help me, I am very thankful.

Thank you

There is no properties which available via the object model. The Ribbon UI is a static thing, to get any dynamism you need to use callbacks defined in the XML markup.

To get the job done you need to use the getVisible attribute for the tab control. When a document is opened/closed you can check out whether the tab should be displayed or not. If required, you can call the Invalidate or InvalidateControl methods of the IRibbonUI interface to force the application to call your callbacks anew. Thus, you can show or hide a tab dynamically.

Read more about the Fluent UI (aka Ribbon UI) in the following series of articles in MSDN:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM