How to determine what a custom toolbar button executes?

J

Jonathan West

Dunedin397 said:
Is it possible to determine what a custom toolbar button will execute?

Thanks.



The Id property of the button defines the built-in command that is run, if
the button runs a built-in command. A custom control has an Id of 1

The OnAction property defines the macro that is run, if the button is
attached to a macro.

If the button is attached to an autotext entry, the ID is 2205 and the
Parameter property gives the name of the autotext entry that is inserted

If the button is attached to a style, the ID is 2321 and the Parameter
property gives the name of the style that is applied.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
D

Dunedin397

Hello Jonathan,

Thanks for replying, but I'm not sure if I got across what I'm trying to do,
which is actually quite basic.

The Word template I'm looking at has a custom toolbar. If I load the
template, either directly or as a new document and select the Tools\Customize
option, I'm right-clicking on the various buttons on our toolbar (or even the
buttons on the Word toolbars), but I can't see what each button will do. I
can edit the name and how each button looks, but not what it'll do.

Thanks again.
 
J

Jonathan West

Dunedin397 said:
Hello Jonathan,

Thanks for replying, but I'm not sure if I got across what I'm trying to
do,
which is actually quite basic.

The Word template I'm looking at has a custom toolbar. If I load the
template, either directly or as a new document and select the
Tools\Customize
option, I'm right-clicking on the various buttons on our toolbar (or even
the
buttons on the Word toolbars), but I can't see what each button will do.
I
can edit the name and how each button looks, but not what it'll do.

Thanks again.

Quite a lot of what the buttons can do can't be changed from the user
interface available when you display the Tools Customize dialog, but only by
writing VBA code to read/write the properties of the relevant
CommandBarControl object. The properties I have given you are the properties
of that object relevant to your question.

There are all sorts of other things you can do to change the behavior of a
button if you use VBA. For instance you can change the tooltip text to
something completely different from the caption & the macro name if you
want.

In practice, quite a lot of what you want to do can be done from the
Immediate window in the VBA editor. For instance typing the following into
the immediate window

? CommandBars("My toolbar").Controls(1).OnAction

will display the macro name associated with the button. You can change the
macro associated with the button by typing in this

CommandBars("My toolbar").Controls(1).OnAction = "Mymacro"


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
D

Dunedin397

Hello Jonathan,

Many thanks for the reply, it's really appreciated. I do find that a little
odd, in that you can create the button but not edit what it does. But there
you go.

Thanks again.

Andy Crawshaw
 
J

Jonathan West

Dunedin397 said:
Hello Jonathan,

Many thanks for the reply, it's really appreciated. I do find that a
little
odd, in that you can create the button but not edit what it does.

I agree! But the problem goes away in Word 2007. There you can't even create
a button on the main toolbar through the UI, only in a single dedicated
area. This is called progress.
But there
you go.

Yup! :)


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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