Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tool bar item 'tip' 1

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
Hey all!

I have a Word document that has a customized tool bar and I need to change the 'tip' that is displayed when the mouse hovers over the button. For instance, if you place the mouse pointer over the picture of the printer it says 'Print'. I'd like to be able to change the 'tip' over my buttons.

These buttons were added to the toolbar by right clicking, selecting customize and going to the Commands tab, selecting Macros and finding the macro I'd like run when the user selects the button.

How do I access the properties of this button on the tool bar and change the tip?

Thanks!



Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases:
The Fundamentals of Relational Database Design
Understanding SQL Joi
 
lespaul,
In Word 2k SR-1 the only way that I know to change the [tt]TooltipText[/tt] using VBA.

Here is an example, this is written to demonstrate the principal and is not necessarily the best way to do it.
Code:
[navy]Sub[/navy] ChangeToolTip(ToolbarName [navy]As[/navy] String)
[navy]On Error Resume Next[/navy]
[navy]Dim[/navy] cb [navy]As[/navy] CommandBar
[navy]Dim[/navy] cbc [navy]As[/navy] CommandBarControl
[navy]Dim[/navy] strTooltipText [navy]As String[/navy]
[navy]Set[/navy] cb = Application.CommandBars(ToolbarName)
[navy]If[/navy] Err.Number <> 0 [navy]Then[/navy]
  MsgBox "Could not find toolbar " & ToolbarName, vbOKOnly, "ChangeToolTip error"
  [navy]Exit Sub[/navy]
[navy]End If[/navy]
[navy]For Each[/navy] cbc [navy]In[/navy] cb.Controls
  strTooltipText = cbc.Tooltip[navy]Text[/navy]
  [navy]If[/navy] Err.Number = 0 [navy]Then[/navy]
    strTooltipText = InputBox("Contol: " & cbc.Caption, "Change tooltip text", strTooltipText)
    [navy]If[/navy] Len(Trim(strTooltipText)) <> 0 [navy]Then[/navy]
      cbc.TooltipText = strTooltip[navy]Text[/navy]
    [navy]End If[/navy]
  [navy]Else[/navy]
    Err.Clear
  [navy]End If[/navy]
[navy]Next[/navy] cbc
[navy]Set[/navy] cbc = [navy]Nothing[/navy]
[navy]Set[/navy] cb = [navy]Nothing[/navy]
[navy]End Sub[/navy]

[navy]Sub[/navy] ChangeToolTip_Test()
ChangeToolTip "Custom 1"
[navy]End Sub[/navy]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
thanks! we'll work with that and see what we can do!

Leslie
 
Thinking aloud - if you have the right properties in a watch window they are accessable for change there. If it is a once only - no more hassle than running script. And a bit more visible.
 
FYI - the tip shown for a macro dragged onto a toolbar is the name of the procedure. It will be this regardless of any renaming of the icon on the toolbar (if you have it as text).

NOTE: renaming the procedure AFTER the macro pointer has been dragged to a toolbar will NOT change the tip. In fact, the macro will no longer run as what you drag to the toolbar is a pointer. If the procedure (macro) is renamed the pointer is no longer valid.

Of course if you rename the procedure, then drag it up again, then the tip will display the new procedure (macro) name.

Gerry
My paintings and sculpture
 
So there's no way to change the tip to something meaningful?

When the macro button is created on the toolbar all it does it take the macro name and perform some conversion on it and make that the tip. For instance, if the macro was named Print[highlight] [/highlight]4 Copies, Word makes the tip Print4 Copies (notice no space anymore), if it's named Print Four Copies, Word makes the tip 'Print Four Copies'. We don't want that tip, we'd like something different.

Thanks!
Leslie
 
lespaul,
I'm running Word 2000 SR-1 and I can change the tooltips as much as I want.

fumei's post is correct, but IMHO, it's a little confusing.

When a you create a new button on a toolbar using the method you described[ul]
[li]The Name ([tt]Caption[/tt]) on the button will default to the name of the macro.[/li]
[li]The [tt]TooltipText[/tt] will default to the name of the Macro.[/li]
[li]The Assign Macro ([tt]OnAction[/tt]) will default to the name of the Macro.[/li][/ul]

All three of these can be changed after the button is created.
The Name can be changed with Toolbars -> Customize...
The [tt]TooltipText[/tt] & [tt]OnAction[/tt] can only be changed with VBA.

And of course if you set the button to fire a specific macro, and then change the name of the macro, the button will stop working.

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Yes, I suppose it was a bit confusing. Thanks CautionMP.

The point being - reiterated once more - you CAN change the tip text, but only with VBA.

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top