PDA

View Full Version : Solved: Hide/Show Ribbon Tab



quickheads
10-01-2010, 12:14 PM
I was reading through your explanation here to another user:

vbaexpress_com/forum/showthread.php?t=19686

When I enter "getVisible=" into my XML for a custom tab, and then re-open my document template I get an error that says:

"The macro cannot be found or has been disabled because of you Macro security settings."

Here's a sample of my XML:



<tab id="CustomTab"label="OMAR" getVisible="something">


If I remove the getVisible it opens fine. If I add it back, I get the error.

What is the big picture I'm missing here. I'm using Word 2007, and I'm referencing the Office 12.0 library.

I would appreciate any help you could offer.

Warm regards,
Dan Yager
QBA Editor
quickheads.com

xld
10-01-2010, 04:11 PM
Doi you have a callback macro called something?

quickheads
10-01-2010, 09:27 PM
What's a callback macro? :dunno

I guess I really am missing the big picture! LOL!

I did a quick search of these forums for "Callback macro" and see that I need to set-up something like this:




Sub something(control As IRibbonControl, ByRef returnedVal)
.....My VBA here .....
End Sub


Is this correct? I'm basically looking for the ability to show or hide the TAB programatically.

I appreciate the help. See sometime I just need a smack to get headed in the right direction.

Thanks,
Dan Yager
QBA Editor
quickheads.com

Paul_Hossler
10-02-2010, 08:48 AM
Each type of Ribbon element has its own callback format


The CustomUI editor

http://openxmldeveloper.org/articles/customuieditor.aspx


has a 'Callback code generator' that you can paste into a module

It also does some other nifty things, and the price is right

Paul

xld
10-03-2010, 04:05 PM
What's a callback macro? :dunno

I guess I really am missing the big picture! LOL!

I did a quick search of these forums for "Callback macro" and see that I need to set-up something like this:




Sub something(control As IRibbonControl, ByRef returnedVal)
.....My VBA here .....
End Sub


Is this correct? I'm basically looking for the ability to show or hide the TAB programatically.

I appreciate the help. See sometime I just need a smack to get headed in the right direction.

Thanks,
Dan Yager
QBA Editor
quickheads.com

So you didn't then :)

Because your CustomUI XML is using getVisible you need a getVisible callback, something like




Sub something(control As IRibbonControl, ByRef returnedVal)

Select Case control.ID

Case "CustomTab": returnedVal = True
End Select
End Sub


But getVisible is only required if at some point you intend to toggle its visibility between True and False. If you want it always visible, just use



<tab id="CustomTab" label="OMAR" >


in the XML

quickheads
10-04-2010, 07:42 AM
Thanks Paul and XLD,
I think I'm getting the hang of it now. :friends:



So you didn't then :)


I didn't. . . but I do now! (It works A LOT better!) LOL!

I have a little more playing around to do to toggle the visibility, but your responses have allowed me to move forward! I really appreciate you getting me aimed in the right direction.

Warm regards,
Dan Yager
QBA Editor
quickheads.com

xld
10-06-2010, 02:00 AM
Let us know how it goes, and if we can help further.

BTW, I visited your website, I had never heard of these before, it made an interesting little foray. Pity they are gone now.

quickheads
10-06-2010, 04:50 AM
I got it working beautifully thanks to you all. I was trying to prevent the ribbon from showing to people who were not members of the management team. This involved grabbing their credentials from Active Directory, and then parsing an XML file out on our intranet to see if they met a certain set of parameters. If so, then I make the ribbon visible.

I had all of the other pieces figured out, I just didn't quite understand the "callback macros" Thanks to you all I was able to put all of the pieces together.

Thanks for the comment on my website as well. The company that made the kits went out of business in 1985, but the Quickie Builders Association has been continuing to help people finish their planes since 1982! There are lots of planes still under construction (including my own) and we are currently trying to involve new builders by making them completely "scratch buildable." Lot's of good stuff happening.

You can see my time lapse video construction log here: quickheads.com/construction-log/

Thanks again,
Dan Yager
QBA Editor
quickheads.com