RunMacro - Stencil Sub - Shape Parameter - How do you get the calling shape?

Started by DJHarris71, September 20, 2021, 05:08:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DJHarris71

Hello,
After much research and testing, I have determined that 'RunMacro' (not CallThis) is required to call a vba sub that exists in the stencil.
The downside to this is I do not see a way to pass the shape parameter (the shape that triggered the RunMacro call), correct?
I have seen suggestions to use CallThis and add a passthrough method in the .vsdm's ThisDocument section.  This is not an option for me.

I would appreciate it very much if someone had a solution to this.  How do I determine which shape triggered the 'RunMacro' event?

Thanks.

Yacine

Quote from: DJHarris71 on September 20, 2021, 05:08:31 PM
I have determined that 'RunMacro' (not CallThis) is required to call a vba sub that exists in the stencil.

This is not true.

=CALLTHIS("mySubName","myProjectName")


PUBLIC sub mySubName(shp as shape)
...


I agree however that Visio messes this sometimes up. In the worst case, make a new stencil, name the project (under properties) and try again.

HTH,
Y.
Yacine

DJHarris71

I have done exactly as you stated, and it does not work.
I also agree it should work.
Per Microsoft's help on the CALLTHIS function:
"If project is specified, Microsoft Visio scans all open documents for the one containing project and calls procedure in that project. If project is omitted or null (""), Visio assumes procedure is in the VBA project of the document that contains the CALLTHIS formula that is being evaluated."

Yet it does not.  I have attached an image of my inputs. What is wrong with it?

DJHarris71

I see the issue. My test file name is the same as my stencil.
Thanks.