开发者

How can I call a VBA macro that is defined in a different file?

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:

fo开发者_如何学运维o.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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜