Change tool Tip for Macros

M

marcia

I have several macros written that we will use in out office. How can i
change the tool tips (info in the yellow box when your cursor is over the
button on the toolbar)? The text that shows up doesn't really explain what it
does.
 
T

Tony Jollans

The same way you would change any other attribute of the control ...

CommandBras("YourCommandBar").Controls("YourControl").ToolTipText = "Whatver
you want it to say".
 
G

Gordon Bentley-Mix on news.microsoft.com

Marcia,

I think Tony may have misunderstood your question. Tony's post provides
direction on how to set the tooltip that's displayed when you place your
cursor over a control on a UserForm. However, the way I interpret it, you
have a custom toolbar that is used to invoke various macros via buttons on
the toolbar, and your question is related to the tooltip that is displayed
when you place the cursor over one of these toolbar buttons. If this is
correct then read on. ;-D

The text of these tooltips is based on the name of the procedure (sub)
that's tied to the button. Basically what Word does is look at the
procedure's name and break it into separate words based on the capitalisation
within the name. Thus if you have a procedure called something like Private
Sub MySpecialMacro, the tooltip that displayed for the toolbar button for
this procedure will be 'My Special Macro'. There are some exceptions to this
- some keywords like 'Insert' are ignored - but that's the gist of it.

What this means in practical terms is that you're very limited on how much
control you have over these tooltips. About all you can do is make your
procedure names as descriptive as possible and hope that your users
understand. The alternative - and I've done this before - is to develop
something like a little help programme to go with your macros. The approach
I've used is through a 'Help' button on the custom toolbar that simply opens
a web page that provides direction on each of the toolbar buttons. However,
there are alternatives. For example, you could have the 'Help' button display
a UserForm that presents the same information or it could open a Word
document or PDF from a known location (e.g. a network share or, depending on
the level of control you have over the environment, even the User Templates
folder).

HTH!
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!
 
G

Gordon Bentley-Mix on news.microsoft.com

GAHHH! Now I feel like a right wally! I had no idea that there was a
..ToolTipText property for controls on a toolbar - although it only makes
sense that there would be. Obviously your advice is perfectly correct Tony,
so please forgive me for suggesting that you might have misunderstood the
OP's question. I guess that's what I get for not reading through the whole
thread. Sorry about that. :-D

Of course, what's missing is how to invoke the process of setting the
..ToolTipText. I can see how it could be done quite easily if the toolbar is
created via code, but I suspect most users don't know how (or don't bother)
to do this; instead they just create the toolbar manually and store it in a
template/document and rely on Word to display it as needed. This is something
that I would never do since I like to have more control over such things, but
how would you do it under this scenario? In an Auto macro of some sort
perhaps?
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!
 
G

Greg Maxey

GAHHH! Now I feel like a right wally! I had no idea that there was a
.ToolTipText property for controls on a toolbar - although it only makes
sense that there would be. Obviously your advice is perfectly correct Tony,
so please forgive me for suggesting that you might have misunderstood the
OP's question. I guess that's what I get for not reading through the whole
thread. Sorry about that. :-D

Of course, what's missing is how to invoke the process of setting the
.ToolTipText. I can see how it could be done quite easily if the toolbar is
created via code, but I suspect most users don't know how (or don't bother)
to do this; instead they just create the toolbar manually and store it ina
template/document and rely on Word to display it as needed. This is something
that I would never do since I like to have more control over such things,but
how would you do it under this scenario? In an Auto macro of some sort
perhaps?
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!






- Show quoted text -

Gordon,

I believe the once it is set it is set for good. No need to do it each
time the document or template is opened. Say I have a toolbar "My
Toolbar" with a control captioned "Tool Tip Demo." I would just run
this code to set the tooltiptext:

Sub SetToolTip()
CommandBars("My Toolbar").Controls("Tool Tip Demo").TooltipText =
"This is the tool tip demo tool tip text"
End Sub
 
G

Gordon Bentley-Mix on news.microsoft.com

Hmmm... So in theory the tooltip text for a particular control could be set
via the Immediate window...

And sure as eggs, when I tried it just now it worked! The tooltip for the
button on my custom toolbar that invokes a macro to display the 'Bookmark'
dialog which used to say "Bookmark" (in spite of the procedure behind it
being called 'InsertBookmark') now says "THIS IS A REALLY COOL THING!" And so
it is!

But it still requires VBA to do it even if the code is run in the Immediate
window. Funny that there isn't a way to do it through the UI, but then I
suppose there are a few other things that can only be done with VBA - like
working with document variables. And if someone is writing a macro anyway, I
guess setting the tooltip text this way wouldn't be too onerous.

Well, that's my new thing for the day. Very cool! Thanks Greg and Tony and
even Marcia for giving me the impetus to explore this functionality.

(And Greg, do you reckon I've used the correct sentence structure and
punctuation with that bit that reads "...which used to say "Bookmark"..."?
Dunno if it's restrictive clause or a non-restrictive clause. Wonder who I
could ask...;-D)
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!
 
T

Tony Jollans

But it still requires VBA to do it ...

The question was asked in the VBA newsgroup. I would have answered
differently (same answer, I suppose, but framed differently) had the
question been asked in, say, docmanagement.

Why some parts of Word are changeable through the UI, and others aren't is
often a mystery. In this case, my guess would be that tooltips are designed
as help for, sometimes clueless, users; if those same users could easily
mess up the information explicitly designed to help them, it would be
failing at the first hurdle, so the ability to change the tooltips, by
virtue of being only available in the VBE, is limited to non-novice users.

--
Enjoy,
Tony

www.WordArticles.com

"Gordon Bentley-Mix on news.microsoft.com"
 
G

Gordon Bentley-Mix

The question was asked in the VBA newsgroup...

Sure, but heaps of questions are asked in this NG that can be - and
frequently are - answered by directing someone to a solution that *doesn't*
require VBA. The creation of custom toolbars in the first place is one such
example - although as I said, I prefer to create toolbars via code so I can
have a bit more control over them and do things like set the .ToolTipText
property (now that I know how ;-D).

And in any case, I'm not disparaging your answer; as I said in a previous
post, I failed to read the thread through to the end and posted an
inaccurate response. I subsequently retracted my response and apologised for
my error. In fact, I even thanked you for teaching me something new. Dunno
what else you want me to do.

I also appreciate your explanation of why toolbar control tooltips can't be
changed through the UI. It makes good sense to me. Thanks again.
 
T

Tony Jollans

I'm not looking for you to do anything, Gordon. I didn't mean anything
against you by most post; I'm sorry if it came over that way.

If anything I was expanding on my rather curt original response, which,
although I did think it sufficient answer to a VBA question, could not be
described as expansive. Yes, you are right that sometimes (even quite often)
the answer to a VBA question is that you don't need VBA, but on this
occasion you do, and I was just offering a guess as to why that may be so.

marcia seems to have been scared off - I hope she reads all this as the
discussion that has ensued should give her a fairly full picture.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top