PDA

View Full Version : Changing/deleting tooltips/screentips for custom toolbar



techdoc
03-28-2007, 03:40 AM
Hi,

My problem is pretty basic but I'm an absolute VB noob. We've defined a custom toolbar for our own formatting styles, with keyboard shortcuts for several of those most frequently used (see toolbar 'MyStyles' in the attached file). I'd like to have those shortcuts displayed as tooltips (a.k.a. ScreenTips) but some of the default tooltips which Word2003 insists on adding (from the keyboard customization dialog) are wrong, and worse yet, they resist all my efforts at removal. For example, I can't get rid of the default tooltip "(Alt+!)" for the style Heading1 - even though that key combination doesn't even exist (I've defined Alt+Ctrl+1, not Alt+Shift+1). Same thing for Headers 2 and 3.

The following macro lets me add my own tooltip text, but it doesn't remove the ones defined automatically by Word, which are always displayed in parentheses:

Public Sub FixToolTip()
Const sToolTip As String = "TooltipText"
Const sTBName As String = "ToolbarName"
Const iBtnIdx As Integer = 12 'Position in toolbar starting from left/top
CommandBars(sTBName).Controls(iBtnIdx).TooltipText = sToolTip
End Sub
Any ideas?

Thanks a lot!
Paul

malik641
03-29-2007, 09:34 AM
Paul,

Welcome to VBAX! :)

Word is displaying the tips because of a CommandBars property "DisplayKeysInTooltips". Why it is showing those particular key commands I'm not sure.

Try this:

Click Tools --> Customize --> Uncheck "Show shortcut keys in Screen Tips"

VBA Solution:

CommandBars.DisplayKeysInTooltips = False


Hope this helps.

techdoc
03-30-2007, 01:23 AM
Thank you, Malik, for taking the time to reply (and for the warm welcome!) - but I don't want to turn the tooltips off completely: I just want to *edit* several of the 'default' tooltips for my custom toolbar buttons (which always appear in parentheses) since they are showing keyboard shortcuts that are wrong.

It would also be nice - but not essential - to be able to delete certain specific tooltips altogether, e.g. for each button that don't have a keyboard shortcut but only repeats the button label that's already in plain view.

(Sorry if I wasn't clear enough before!)

fumei
03-30-2007, 02:34 AM
It repeats the button label because by default, the value of the Caption property is used as the ScreenTip.

Setting the .ToolTipText property will override the default.

techdoc
03-30-2007, 03:35 AM
Thanks Gerry, but that's exactly what I've been trying: the problem is that Word doesn't override the default but retains it, only prepending my customized ScreenTip text.

Example: The "Heading 1" toolbar button has been assigned the shortcut Alt+Ctrl+1. Word erroneously displays its own ScreenTip "(Alt+!)".
When I use:
CommandBars("MyStyles").Controls(1).TooltipText = "Heading 1 (Alt+Ctrl+1)"
then Word changes the ScreenTip to:
Heading 1 (Alt+Ctrl+1) (Alt+!)
Is there some sort of parameter setting I'm missing here to *replace* the erroneous default (Alt+!) with my own Alt+Ctrl+1 instead of *prepending* it?
(Or is the sample file attached to my first post working correctly at your end? That would be really bizarre indeed, since the misbehavior's reproducible on several different people's machines here.)

It all seemed so simple at the outset... :beg:

Thanks again,
Paul

fumei
03-31-2007, 04:40 PM
In your file, Heading 1 shows Alt-Ctl-1 at this end. It does not show Alt-!

malik641
03-31-2007, 08:18 PM
In your file, Heading 1 shows Alt-Ctl-1 at this end. It does not show Alt-!For me, it didn't either at first. Until I turned on "Show shortcut keys in screen tips" as I described before. Was that checked when you saw "Alt-!" was not there?

fumei
04-01-2007, 12:50 PM
Hmmm. OK. Yes, it is doing it. Hmmmm.

I am going to have to look at this later, as I am a bit swamped right now, but it IS curious.

BTW: I suggest you use Option Explicit in your code modules.

techdoc
04-03-2007, 06:43 AM
Thanks guys - I appreciate your help!

techdoc
04-16-2007, 06:38 AM
Hi again - any more/new ideas? I'm still stuck... :dunno
Thanks,
Paul