Determine which toolbar button was pressed?

S

spyd3r

Okay, I would like to dynamically build a menu of items to be inserted. This
menu would be created based upon the existence of files in a certain
directory. The filename of each item would be used as the name of the menu
button for each item.

Everytime one of those dynamically-created buttons is pressed, I'd like it
to call a bit of code that inserts the same-named item. The only way I can
think of to do this (without maintaining a list of the possible items to
insert somewhere), would be to call one standard macro which knows what
button on the toolbar was pressed, as the button's name would correspond to
the file's name.

Is this possible at all? Or are there any better solutions? Thanks for any
help!
 
J

Jean-Guy Marcil

spyd3r was telling us:
spyd3r nous racontait que :
Okay, I would like to dynamically build a menu of items to be
inserted. This menu would be created based upon the existence of
files in a certain directory. The filename of each item would be
used as the name of the menu button for each item.

Everytime one of those dynamically-created buttons is pressed, I'd
like it to call a bit of code that inserts the same-named item. The
only way I can think of to do this (without maintaining a list of the
possible items to insert somewhere), would be to call one standard
macro which knows what button on the toolbar was pressed, as the
button's name would correspond to the file's name.

Is this possible at all? Or are there any better solutions? Thanks
for any help!

Try something like:

Dim strButtonCaption As String

strButtonCaption = Application.CommandBars.ActionControl.Caption

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
[email protected]
Word MVP site: http://www.word.mvps.org
 
Top