actions in stencil master are lost at drop

K

Kati Molnar

I added actions referring to VBA macros to my master in a stencil. The VBA
macros are in the stencil, too. When I drop the master on a drawing, the
master gets copied to the document stencil, and the actions are gone, both on
the document and in the document stencil. Is there a way to ensure that the
actions in the master are inherited in the instance on the document?

My actions work fine when I assign them directly to the shape in the
document.
I use Visio Professional 2003.

Kati Molnar
 
D

David Parker [Visio MVP]

Check that you only have one shape in the master, otherwise Visio will
automatically create a group, resulting in the appearance of missing
actions, custom properties, etc.
 
K

Kati Molnar

David, your recommendation helped. My shape was a group indeed. Now I get the
actions in the dropped shape when I right click on it. However, the macro
invocation is still wrong somehow. I use
RUNMACRO("StencilName.ModuleName.Subname") formula in the master shape
action. I can run the same macro with the same reference from
Tools/Macros/StencilName/ModuleName/SubName on the main menu and it works
properly. But when I select it from the pop-up menu on the dropped shape, I
get

System Error &H800040005 (-2147467259) Unspecified Error

Kati
 
D

David Parker [Visio MVP]

I generally use CALLTHIS when calling VBA code from a shape.
BTW, I don't think it is StencilName, but Stencil VBA Project Name.
 
K

Kati Molnar

I post the solution for those with similar problems.

1. When designing the master shape, be aware that it is almost always a
group. A single shape with a textbox in it is a group already. Select the
border of the group when assigning actions on the shapesheet in the stencil
or when trying to invoke the action on the shape in your drawing.

2. StencilName is an alias for the VBA Project Name of the stencil from now
on.

3. You want to use your VBA macro from the stencil as an action on the
master shape. Your action will be:
RUNMACRO("StencilName.ModuleName.SubName"). Note that
"StencilName.ModuleName.SubName" is an available choice in Edit/Action ->
Action/Run Macro selection list when you are designing the action for the
master shape in the stencil. RUNMACRO is generated by Visio.

4. Referencing VBA code from a stencil is not automatic in the drawing, even
if you dropped a shape from the stencil already. Connect the VBA code of the
stencil to your drawing via Tools/References in the VBA editor for the
drawing and check the StencilName. This will create a Reference entry in the
VBA project of your drawing.

Thanks for David Parker for helping to figure this out.

Kati
 
M

Markus Breugst

Hi Kati,

just one little comment to the following sentence:
A single shape with a textbox in it is a group already.

You don't need to build a group just for adding a text to your shape, since
every Visio shape has its own "Text" property.

I just mention this because the extensive use of groups reduces the
performance of Visio, especially if you have a large amount of shapes in
your drawing.

The menu "Shape -> Operations" offers interesting possibilities for
designing complex shapes withoug groups.

Best regards,
Markus
 

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