问题
The situation is the following:
Macro Foo is defined in File foo.vss Macro Bar is defined in File bar.vsd.
Bar() is at some point supposed to call Foo(). Is that possible?
If it helps:
foo.vss is a stencil file that is opened in bar.vsd.
FYI:
They are forcing me to use Visio/vba. Its a strange old System that generates SQL from the diagrams, really ugly.
回答1:
This is possible, using the ExecuteLine method on the document containing the code.
So in your example it would be something like:
Visio.Documents("Foo.vss").ExecuteLine "Foo"
I've used this quite a bit for calling Visio macros from Excel and it's worked quite nicely. ExecuteLine seems like it will execute pretty much anything you can execute from the Immediate Window, so you actually are passing in a line of valid VBA code...
Hope that helps
回答2:
Never worked with visio before, but a quick browse got me these for excel vba; I'm not sure if it'll work for you, but try it out:
http://www.vbaexpress.com/kb/getarticle.php?kb_id=279
http://www.xtremevbtalk.com/showthread.php?t=139135
来源:https://stackoverflow.com/questions/1669377/how-can-i-call-a-vba-macro-that-is-defined-in-a-different-file