Need to find commands behind a ToolBarPopup control

C

cwadams

I've inherited a couple of Word templates which have custom toolbars, one of
which has a button, "Report AutoText", which opens a popup menu. One of the
submenu options is "Insert FramedFigure", which appears to do some formatting
and then inserts a small logo image. I can't find any code anywhere in the
macros that does this, and can't find any kind of a link to the image so it
can be changed. How do you identify the commands that run behind one of
these ToolBarPopup controls?
 
L

Lene Fredborg

You can use OnAction of a command to return the name of the macro associated
with a command.

In VBA, a toolbar command is a Control and a toolbar is a CommandBar. A
control itself can hold one or more controls. If you have a popup-menu with a
list of commands and if a command in that menu has a submenu, the commands in
that submenu will be a control of a control of a control of the CommandBar.

Examples:

The following line will display the name of the macro associated with the
third command (.Controls(3)) in the toolbar named “MyToolbarâ€:

MsgBox CommandBars("MyToolbar").Controls(3).OnAction

Instead of the index number of a command, you can use the name of the command:

MsgBox CommandBars("MyToolbar").Controls(“Insert FramedFigureâ€).OnAction

In case of a command in a popup menu (like your example), it could look like
this (replace 3 by the name or the index number of the popup menu):

MsgBox CommandBars("MyToolbar").Controls(3).Controls(“Insert
FramedFigureâ€).OnAction

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
C

cwadams

Thanks, but I've tried that, and the OnAction property returns nothing. Is
it possible for one of these popup controls to run code external to the
document it's contained in? I know, for instance, it could run a macro
contained in another template which is referenced, but when I open this
template, I don't see any others referenced (and there is no maco name shown
in the OnAction property, anyway.)
 
J

Jonathan West

cwadams said:
Thanks, but I've tried that, and the OnAction property returns nothing.
Is
it possible for one of these popup controls to run code external to the
document it's contained in? I know, for instance, it could run a macro
contained in another template which is referenced, but when I open this
template, I don't see any others referenced (and there is no maco name
shown
in the OnAction property, anyway.)

If the OnAction property returns nothing, then the button is running a
built-in command. The ID property of the button returns a number uniquely
associated
with that command, and the Caption, TooltipText and DescriptionText
properties all offer information about the command
 
C

cwadams

Hm. Well, the .ID is 2205, the ToolTipText is "FramedFigure", and the
DescriptionText is "Inserts the indicated AutoText entry in the document."

Of course, all of this was obvious from the caption, except for the ID.
I've noticed also that several other buttons on the toolbar have the same ID
number, though they perform different tasks.

Now, here's the next thing I notice: if I click "Insert" on the Standard
menu bar, then "AutoText" - "Graphic - Framed" - "Framed Figure", I get
exactly the same result, which leads me to believe that he simply added that
command to his custom toolbar, but it still doesn't explain where the image
is coming from. Since the "Insert Framed Figure" command doesn't *ask* for a
figure to insert, how does it know what image to use and where to find it?
Is there something in the Options that I'm not seeing?
 
G

Gordon Bentley-Mix

Sounds to me like you have an AutoText entry stored somewhere - possibly in
the template - called "Framed Figure" and the custom menu command is simply
calling the standard Word functionality for inserting this AutoText entry.
Accordingly, to change the image it's simply a matter of modifying the
AutoText entry, which is done using standard Word functionality.
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
J

Jonathan West

Gordon Bentley-Mix said:
Sounds to me like you have an AutoText entry stored somewhere - possibly
in
the template - called "Framed Figure" and the custom menu command is
simply
calling the standard Word functionality for inserting this AutoText entry.
Accordingly, to change the image it's simply a matter of modifying the
AutoText entry, which is done using standard Word functionality.


Aha. That's the piece in the puzzle! I've got it now.

The button was created using the Tools Customize dialog, by dragging an
AutoText entry to the toolbar. I've just repeated the process. The ID of the
resulting button is 2205, and the Parameter property of the button contains
the name of the AutoText entry that is inserted.
 
C

cwadams

Ooookay. So, setting a breakpoint so I can look at the properties, the
parameter just says "FramedFigure". I take it, then, that what he did was
actually build this framed figure (It's a full-page frame with multiple
sections, tables, several data fields, and the logo image) and saved the
entire thing as something called simply, "FramedFigure"? Wonderful.

So, is there any way to edit this stuff (all I need to change in the framed
firgure is the image,) or do I actually need to:
1. insert the framed figure on a blank page,
2. delete the FF from the toolbar,
3. replace the image in the frame,
4. put the new FF on the toolbar,
5. clear the page I was working on,
6. and then re-save the template?

Thanks for the assistance, folks. Obviously, this stuff is new to me. I've
used Word for years, but never had any need for this kind of function, so
trying to decipher what someone else put together has been an exercise in
frustration.
 
J

Jonathan West

cwadams said:
Ooookay. So, setting a breakpoint so I can look at the properties, the
parameter just says "FramedFigure". I take it, then, that what he did was
actually build this framed figure (It's a full-page frame with multiple
sections, tables, several data fields, and the logo image) and saved the
entire thing as something called simply, "FramedFigure"? Wonderful.

Correct. That something is an AutoText entry named FramedFigure. Go to
Insert, AutoText, AutoText... and you will see the list of available items.


So, is there any way to edit this stuff (all I need to change in the
framed
firgure is the image,) or do I actually need to:
1. insert the framed figure on a blank page,
2. delete the FF from the toolbar,
3. replace the image in the frame,
4. put the new FF on the toolbar,
5. clear the page I was working on,
6. and then re-save the template?

Thanks for the assistance, folks. Obviously, this stuff is new to me.
I've
used Word for years, but never had any need for this kind of function, so
trying to decipher what someone else put together has been an exercise in
frustration.

Not quite. Proceed as follows

1. Insert the framed figure on a blank page
2. Replace the image in the frame
3. Select the frame.
4. Go to Insert, AutoText, AutoText...
5. On the dialog that appears, at the bottom set "Look in" to the name your
template
6. Put "FramedFigure" into the "Enter AutoText entries here" box and then
click Add.iIf prompted to replace the existing autotext entry, click Yes.
7. Click OK to close the dialog. Delete the frame and then save the
template.

The original button should still work, but now will insert the frame with
the new image.
 
C

cwadams

That got it. Great, thanks!

Jonathan West said:
Correct. That something is an AutoText entry named FramedFigure. Go to
Insert, AutoText, AutoText... and you will see the list of available items.




Not quite. Proceed as follows

1. Insert the framed figure on a blank page
2. Replace the image in the frame
3. Select the frame.
4. Go to Insert, AutoText, AutoText...
5. On the dialog that appears, at the bottom set "Look in" to the name your
template
6. Put "FramedFigure" into the "Enter AutoText entries here" box and then
click Add.iIf prompted to replace the existing autotext entry, click Yes.
7. Click OK to close the dialog. Delete the frame and then save the
template.

The original button should still work, but now will insert the frame with
the new image.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
 

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