tool tips for macros

K

koolnuts

If it is a toolbar button which runs a macro, then you can set the tooltip by:

CommandBars("CommandBarName").Controls("ControlName").TooltipText = "Click
for help on ..."
or

Set myCtrl = CommandBars.ActionControl
myCtrl.TooltipText = "Click for help on ..."
.....
Set myCtrl = nothing

If it is a MacroButton field - I am sorry but I don't know of a way to set a
tooltip on a field.

Regards
koolnuts
 
P

papagru

it is a button that runs a macro, and your answer looks authoritative to me.
However, I know less than you think. It looks like I am supposed to plop
these lines into the macro, and I will try this. But can you tell me a
little more about what each line does.
Many thanks
P
 
P

papagru

Trying to make my question very specific. Here's a *macro* to convert a
selection to Sentence case. When I hover over the button, it says LC where I
wish it would say "sentence case".
Sub LC()
' LC Macro sets sentence case
Selection.Range.Case = wdTitleWord
End Sub
So what would I type in to do that?
P
 
C

Charles Kenyon

The quick and dirty way to do it is to name your macro SentenceCase. The
default tooltip for the button will be "Sentence Case." I know that you can
also use vba to assign a tooltip other than the name to a particular button,
but I've never bothered to learn how to do this. It would, though, be a
separate macro that you run once to assign the tooltip, not everytime your
referenced macro is run.
 
K

koolnuts

How are you creating the button on the toolbar / CommandBar?

There are at least two ways to do this:

1. is through code, which then allows you to change the tooltiptext
property, eg.

Sub MyCreateCommandBar
Dim cbar As CommandBar
Set cbar = CommandBars.Add(Name:="CommandBarName", Position:=msoBarTop,
Temporary:=False)

With CommandBars.Item("CommandBarName").Controls
' Add cmdToggleBold button
.Add Type:=msoControlButton, ID:=1
.Item(1).Caption = "Toggle Bold"
.Item(1).DescriptionText = "Toggle Bold"
.Item(1).TooltipText = "some text some text some text some text"
.Item(1).FaceId = 113
.Item(1).OnAction = "cmdToggleBold"
.Item(1).Enabled = True
End With
cbar.Visible = True
cbar.Enabled = True
set cbar = nothing
End Sub

You would then call MyCreateCommandBar from an AutoExec or AutoOpen or
AutoNew macro which ever is appropriate.

2. is by customising a commandbar in Word, eg.
Tools->Customise->Commands->Macros->select a macro name and drag it to the
CommandBar. Unfortunately this does not allow you to change the TooltipText
property other than by using code.

CommandBars("CommandBarName").Controls("ControlName").TooltipText = "Click
for help on ..."

which you would then also put into a AutoExec or AutoOpen or AutoNew macro
so it would setup the button as soon as the document is opened, executed
(AutoExec for loading global templates / documents) or created (AutoNew).
 
P

p

Thanx, I really appreciate your help and time.
P

koolnuts said:
How are you creating the button on the toolbar / CommandBar?

There are at least two ways to do this:

1. is through code, which then allows you to change the tooltiptext
property, eg.

Sub MyCreateCommandBar
Dim cbar As CommandBar
Set cbar = CommandBars.Add(Name:="CommandBarName", Position:=msoBarTop,
Temporary:=False)

With CommandBars.Item("CommandBarName").Controls
' Add cmdToggleBold button
.Add Type:=msoControlButton, ID:=1
.Item(1).Caption = "Toggle Bold"
.Item(1).DescriptionText = "Toggle Bold"
.Item(1).TooltipText = "some text some text some text some text"
.Item(1).FaceId = 113
.Item(1).OnAction = "cmdToggleBold"
.Item(1).Enabled = True
End With
cbar.Visible = True
cbar.Enabled = True
set cbar = nothing
End Sub

You would then call MyCreateCommandBar from an AutoExec or AutoOpen or
AutoNew macro which ever is appropriate.

2. is by customising a commandbar in Word, eg.
Tools->Customise->Commands->Macros->select a macro name and drag it to the
CommandBar. Unfortunately this does not allow you to change the TooltipText
property other than by using code.

CommandBars("CommandBarName").Controls("ControlName").TooltipText = "Click
for help on ..."

which you would then also put into a AutoExec or AutoOpen or AutoNew macro
so it would setup the button as soon as the document is opened, executed
(AutoExec for loading global templates / documents) or created (AutoNew).
 
R

Robert Werner

How is it possible to set an AutoOpen macro to run another macro.

After following this thread I changed the macro name to AutoOpen for hiding
a standard toolbar and displaying my custom toolbar. The macro now works the
way i had originally intended, but it occurs to me that there may be other
macros i'd like to run using AutoOpen. So perhaps i can set up a series of
macros then run them by referenc ein the AutoOpen macro. Is that how it works?
Being new to VB I'm not sure how to do the scripting nor what can be done.
 

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