Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

How to determine what a custom toolbar button executes?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dunedin397 - 25 Apr 2007 15:38 GMT
Is it possible to determine what a custom toolbar button will execute?

Thanks.
Jonathan West - 25 Apr 2007 16:31 GMT
> 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.

Signature

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

Dunedin397 - 25 Apr 2007 16:54 GMT
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.

> > Is it possible to determine what a custom toolbar button will execute?
> >
[quoted text clipped - 11 lines]
> 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.
Jonathan West - 25 Apr 2007 17:16 GMT
> Hello Jonathan,
>
[quoted text clipped - 12 lines]
>
> 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"

Signature

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

Dunedin397 - 26 Apr 2007 09:42 GMT
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

> > Hello Jonathan,
> >
[quoted text clipped - 34 lines]
>
> CommandBars("My toolbar").Controls(1).OnAction = "Mymacro"
Jonathan West - 26 Apr 2007 10:31 GMT
> 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! :-)

Signature

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.