Running a macro stored in another Visio drawing or an external fil

T

TimBradt

I am trying to determine a way to run a macro inside a Visio document that
actually accesses the source stored in another file. We have a Visio doc
that may be customized for any given application, and I want to run a common
macro regardless of the customizations. I'm trying to avoid a macro change
having to be made in 1..n Visio docs, and instead just release a new macro
file.

I'm not picky on what the other, external file is - it could be another
Visio doc or just a .cls or .bas file. It appears that Excel handles this
nicely, but I haven't determined for sure if Visio does or doesn't. Can
anyone tell me if there is a way to do this?
 
E

emel

Hi Tim,

It turns out to be easy to do exactly what you're after. Just put your
macro in a separate shapes (aka stencil, .vss) file instead of the visio
drawing (.vsd) file itself.

With your drawing open, create a new stencil file. (FILE / SHAPES / NEW
STENCIL). Start the Visual Basic editor (alt F11) . There will be separate
projects for your drawing (.vsd) and stencil (.vss). The stencil will be
named something like Stencil1. Insert a new module in the stencil project
and macro to your heart;'s content.

Save the stencil in a folder that will exist on all of the destination PCs.
(My Shapes is the default, I believe.) When you save the drawing, it will
save a link to the stencil file. When anyone else opens the drawing on their
PC, it will look for the stencil in their My Shapes folder. To update the
macro, just redistribute the stencil file and tell folks to save it in My
Shapes. Next time they open the drawing, it will link to the updated
stencil and macro. The stencil file name has to remain constant (say,
TimsMacro.vss) for this to work.

There are various tangles with setting security levels and having firewalls
strip off attachments with embedded macros, but let's leave that for another
day. This ought to get you started.

Two last things. 1) We do this all the time in my company. It works great.
2) This is all relative to Visio 2003. I suspect that 2007 runs similarly.

Hope that helps,

Ed
 
D

Dominik Jenzer

Hi Ed

Your solution would also fits to my problem...

But it seems that I cant add a macro to my stencil (Visio 2007). The VBA-Editor does not show any stencil-project.

Open the stencil itself an using the macro-menu to create a new one will remain in an error message called: Visio can not create the macro, because the creation of VBA-Project are disabled (free translated from the german message).

Where do I find the proper setting to enable VBA-Projects for stencils?

Thanks for any response



eme wrote:

Hi Tim,It turns out to be easy to do exactly what you're after.
03-Okt-08

Hi Tim

It turns out to be easy to do exactly what you're after. Just put your
macro in a separate shapes (aka stencil, .vss) file instead of the visio
drawing (.vsd) file itself

With your drawing open, create a new stencil file. (FILE / SHAPES / NEW
STENCIL). Start the Visual Basic editor (alt F11) . There will be separate
projects for your drawing (.vsd) and stencil (.vss). The stencil will be
named something like Stencil1. Insert a new module in the stencil project
and macro to your heart;'s content

Save the stencil in a folder that will exist on all of the destination PCs.
(My Shapes is the default, I believe.) When you save the drawing, it will
save a link to the stencil file. When anyone else opens the drawing on their
PC, it will look for the stencil in their My Shapes folder. To update the
macro, just redistribute the stencil file and tell folks to save it in My
Shapes. Next time they open the drawing, it will link to the updated
stencil and macro. The stencil file name has to remain constant (say,
TimsMacro.vss) for this to work

There are various tangles with setting security levels and having firewalls
strip off attachments with embedded macros, but let's leave that for another
day. This ought to get you started.

Two last things. 1) We do this all the time in my company. It works great.
2) This is all relative to Visio 2003. I suspect that 2007 runs similarly.

Hope that helps

Ed

Previous Posts In This Thread:

On Mittwoch, 1. Oktober 2008 14:39
TimBrad wrote:

Running a macro stored in another Visio drawing or an external fil
I am trying to determine a way to run a macro inside a Visio document that
actually accesses the source stored in another file. We have a Visio doc
that may be customized for any given application, and I want to run a common
macro regardless of the customizations. I'm trying to avoid a macro change
having to be made in 1..n Visio docs, and instead just release a new macro
file

I'm not picky on what the other, external file is - it could be another
Visio doc or just a .cls or .bas file. It appears that Excel handles this
nicely, but I haven't determined for sure if Visio does or doesn't. Can
anyone tell me if there is a way to do this?

On Freitag, 3. Oktober 2008 13:27
eme wrote:

Hi Tim,It turns out to be easy to do exactly what you're after.
Hi Tim

It turns out to be easy to do exactly what you're after. Just put your
macro in a separate shapes (aka stencil, .vss) file instead of the visio
drawing (.vsd) file itself

With your drawing open, create a new stencil file. (FILE / SHAPES / NEW
STENCIL). Start the Visual Basic editor (alt F11) . There will be separate
projects for your drawing (.vsd) and stencil (.vss). The stencil will be
named something like Stencil1. Insert a new module in the stencil project
and macro to your heart;'s content

Save the stencil in a folder that will exist on all of the destination PCs.
(My Shapes is the default, I believe.) When you save the drawing, it will
save a link to the stencil file. When anyone else opens the drawing on their
PC, it will look for the stencil in their My Shapes folder. To update the
macro, just redistribute the stencil file and tell folks to save it in My
Shapes. Next time they open the drawing, it will link to the updated
stencil and macro. The stencil file name has to remain constant (say,
TimsMacro.vss) for this to work

There are various tangles with setting security levels and having firewalls
strip off attachments with embedded macros, but let's leave that for another
day. This ought to get you started.

Two last things. 1) We do this all the time in my company. It works great.
2) This is all relative to Visio 2003. I suspect that 2007 runs similarly.

Hope that helps,

Ed

On Mittwoch, 3. Dezember 2008 21:48
Kyle H wrote:

Running a macro stored in another Visio drawing or an external fil - eme
How do you call a macro from a different Visio File?

Thanks!

EggHeadCafe - Software Developer Portal of Choice
Spyware-Adware-Internet Driver License Test Redux
http://www.eggheadcafe.com/tutorial...df9-f1efa2b6054a/spywareadwareinternet-d.aspx
 

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