Better tooltips for commandbar buttons?

S

StargateFan

In the new toolbar I've been working on in a Word doct., I've found
that the description is the part that is weak. In Excel, the name of
the macro is one thing, the descriptive text that shows up when the
mouse is hovered over each button is another. These 2 things are
separate. Unlike Excel, I'm not building this floating commandbar up
through code, I've just been attaching macros to a toolbar I created.

Is there a way to be able to put a better description than what occurs
when the tooltip just repeats the text of the macro name?

Thanks.
 
K

Klaus Linke

Hi,

A simple way would be to put in the following line into the macro.
Then run the macro once by clicking on the button.

CommandBars.ActionControl.DescriptionText = "Hello World"

After doing that, you can delete the line.

Regards,
Klaus
 
K

Klaus Linke

Sorry, should have been
CommandBars.ActionControl.TooltipText = "Hello World"

Klaus
 
S

StargateFan

Hi,

A simple way would be to put in the following line into the macro.
Then run the macro once by clicking on the button.

CommandBars.ActionControl.DescriptionText = "Hello World"

After doing that, you can delete the line.

Regards,
Klaus





Sorry, should have been
CommandBars.ActionControl.TooltipText = "Hello World"

Klaus

I'm sorry, you lost me. I don't think that you mean instead of
descriptive text that gets written into the doct. each time and then
we have to delete. So can you pls clarify?

Thanks much. :eek:D
 
K

Klaus Linke

I'm sorry, you lost me. I don't think that you mean instead of
descriptive text that gets written into the doct. each time and
then we have to delete.

Now you lost me...
So can you pls clarify?

You have a toolbar, and you have some buttons on it that run macros.

If you click on a button, the macro code runs.

Inside the macro, you can tell which button was used to call the macro, it's
CommandBars.ActionControl

You can use that fact to set properties of the button, say change the
description text that you'll see when you customize the interface:
CommandBars.ActionControl.DescriptionText = "myNewDescriptionText"
or the Tooltip Text that you see when you hover over the button
CommandBars.ActionControl.TooltipText = "myNewTooltipText"
or in fact any other property of the control/button.

After you have added the line to the macro, you need to run the macro once
by clicking on the button.
(Running the macro any other way would not do, since the line you added
needs to establish the ActionControl, that is, the button you want to
change).

After that happened, you can delete the line from the macro: The property
has been changed, and the line is no longer needed.

An alternative way would be to address the control directly. But for that,
you'd need to know the command bar you are dealing with (say its name), and
the control button you want to change (say its index:
CommandBars("myToolbar").Controls(13).TooltipText = "myNewTooltipText"
You could run a line like that once, in the immediate window, or in some
scratch macro.

Regards,
Klaus
 
S

StargateFan

Now you lost me...

<g> No worries. I didn't understand but you explained it below. We
don't see that text each time, it's done once to change a property,
the tooltip one if I've understood correctly, and then that's set.
Very kewl.
You have a toolbar, and you have some buttons on it that run macros.

If you click on a button, the macro code runs.

Inside the macro, you can tell which button was used to call the macro, it's
CommandBars.ActionControl

You can use that fact to set properties of the button, say change the
description text that you'll see when you customize the interface:
CommandBars.ActionControl.DescriptionText = "myNewDescriptionText"
or the Tooltip Text that you see when you hover over the button
CommandBars.ActionControl.TooltipText = "myNewTooltipText"
or in fact any other property of the control/button.

After you have added the line to the macro, you need to run the macro once
by clicking on the button.
(Running the macro any other way would not do, since the line you added
needs to establish the ActionControl, that is, the button you want to
change).

After that happened, you can delete the line from the macro: The property
has been changed, and the line is no longer needed.

An alternative way would be to address the control directly. But for that,
you'd need to know the command bar you are dealing with (say its name), and
the control button you want to change (say its index:
CommandBars("myToolbar").Controls(13).TooltipText = "myNewTooltipText"
You could run a line like that once, in the immediate window, or in some
scratch macro.

My tips folder just keeps getting bigger and bigger with all the info
I've been adding to it lately. So besides changing the macros
themselves in this way above, this is also getting saved to my "tips"
folder "database". Thanks, Klaus! :eek:D
 

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