• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Displaying only one Ribbon Tab Dynamically

Jordan

Member
Hey everyone! Here is my problem. I have an Excel application whose tab navigation is implemented through buttons on a Ribbon tab instead of buttons in a spreadsheet. So far, I've successfully created a new "Navigation" tab to display these buttons and execute their callbacks.


The tab menu sits in a seperate .xlam file which I've loaded as in Add-In. By default, the tab menu does not appear on the ribbon -- that is, it's visibility always set to false unless otherwise specified. When one opens the correct spreadsheet, a command in the Workbook_Open procedure of that spreadsheet makes a call to the .xlam file to change the tab's visibility setting to true. In this way, I am able to have the navigation tab always sitting in the background whenever someone opens Excel; thus, the navigation tab is only enabled when the correct file is open.


Hopefully I haven't lost you yet. The problem is that I don't really care for the other tabs - I only want my tab to be displayed. If I set startFromScratch="false" in the xlam file, it will always remove every tab regardless of whether my .xlam menu is visible or not. Moreover, I don't think there is a getStartFromScratch callback like there is for the visibile property (I could be wrong about this - in fact, I hope I'm wrong about this!). Does anyone have any ideas on what I can do to only show my one tab when a specific file is loaded in Excel?


Thanks,

Jordan
 
Ron gives several examples/methods for hiding the built-in ribbons and displaying a custom ribbon. There's slight differences depending on whether you're using 2007 or 2010. Perhaps one of them would be helpful?

http://www.rondebruin.nl/ribbon.htm
 
Well the GetVisible part of Ron's work was very helpful - in fact, it's how I created the mechnism to display/hide the workbook based on what file is currently open. One workaround I could see for this is to set each of the standard Ribbon item's visibility to false. The problem with this method is that the user could have other addin tabs open which I wouldn't be able to close. Hmmmmmm
 
The workaround I see it to basically use a helper sheet to create a log of all toolbars available to user, and record the original settings for each one. Painful, but robust.
 
I think you're right :/. Thanks for the help, Luke.


In the mean time, I've employed Andy Pope's RibbonEditor (http://www.andypope.info/vba/ribboneditor_2010.htm) which has allowed me to set the visibility of the default tabs pretty quickly based on what's opened.
 
Back
Top