Call VBA Code Stored in a Stencil

Started by LarsRasmussen, March 24, 2015, 01:48:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarsRasmussen

Dear Visguys!

I am new to your World  :) and I hope you can help me here:

I need to store my (first) VBA program in a stencil, so the user can call it from multiple drawings. But even though the macro runs easily when executed directly from the Macro-list, I can't run it by the assigned shortcut (eg. Ctrl+Shift+Q).

I also can't run it from another macro by Executeline, RunMacro. Below  is an example, where it doesn't even work within the same document:


Sub LR()     
    Callthis ("thisdocument.minTest")
    Runmacro ("thisdocument.minTest")
    Runaddon ("thisdocument.minTest")   
End Sub



Sub MinTest()
   MsgBox "der"
End Sub

What am I missing?  :-[


JuneTheSecond

#1
CallThis, RunMacro and RunAddon are shapesheet functions.
For more details, please refer to the online documents in Officet Dev Center.
https://msdn.microsoft.com/en-us/library/office/jj945061.aspx
Best Regards,

Junichi Yoda
http://june.minibird.jp/

LarsRasmussen

#2
Thanks, sorry I see that now.

But my problem is still to run a "Stencil-macro" by a short-cut key or from a "document-macro". That should be possible, shouldn't it?

JuneTheSecond

#3
Another documents can be referred by their projects name.
VBA editor window has a list of projects.
Functions to run macro have option to indicate project name.
Format for coding differs among functions.
Please carefully read the online document at
https://msdn.microsoft.com/en-us/library/office/jj945061.aspx
Best Regards,

Junichi Yoda
http://june.minibird.jp/

LarsRasmussen

#4
Thanks, I will search for the solution on msdn.

Yacine

Having spent some hours on this problem today, I thought it may be good to "store" it in the forum.
The solution is to not call the stencil directly, but as document of the application:
Visio.Documents("Foo.vss").ExecuteLine "Foo"
(found here: http://stackoverflow.com/questions/1669377/how-can-i-call-a-vba-macro-that-is-defined-in-a-different-file)
Yacine