still can't access subroutines in stencil from shapesheet action

Started by jrinn, November 09, 2010, 01:01:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jrinn

I've read a bunch of the posts in this forum and it looks to be a piece of cake to point to a macro in a stencil and call it out via a shapesheet action or event.  I had a simplified version working when all were in the same file, but now I'm trying to do what it looks like can be done and I'm getting stiffled.

I created some shapes with a double click event calling out macros different ways.  I had to resort to adding the macros locally and renaming them just to see if I was doing something really stupid.  I'm still having major problems.  I've tried using dozens of variations of RUNMACRO, CALLTHIS, RUNADDON, RUNADDONWARGS,...

Can someone please check out this simple code and tell me what I'm doing wrong?

Thanks,
   JPR


Nikolay

I think you can't call a macro in a stencil from shape sheet directly.
Why did you think you could do that?

Jumpy

You can only do it with Callthis. First arg is the procedure name in "quotation marks", followed by the project name. The project name is the stencil name.

http://msdn.microsoft.com/en-us/library/ms406651%28office.12%29.aspx

Nikolay

Ups. I was wrong. It is perfectly possible. Sorry ::)
Just change your functions in the stencil so that they accept SHAPE (!!!) as first argument, and then all other arguments. Like this:


CALLTHIS("ThisDocument.MacroArgumentPassingNone","macros")

CALLTHIS("ThisDocument.macroArgumentPassingString","macros","SomeString")



Public Sub MacroArgumentPassingNone(s As Shape)
    MsgBox ("nothing was passed")
End Sub

Public Sub macroArgumentPassingString(s As Shape, ByVal PassString As String)
    MsgBox ("a single string was passed = " & PassString)
End Sub

jrinn

Worked great!  Thank you both.

Yeah I was following all of the online help with no luck, but the key was to also declare the shape as a variable when using CALLTHIS.  This was counter-intuitive to me since I was trying to match up and have the same number of arguments (as most other code requires). Is that also necessary if you use RUNMACRO, RUNADDON or RUNADDONWARGS?

From now on I'm not going to waste a whole day before sacrificing my pride and asking for help.
Thanks again.
    JPR

Nikolay

Don't sweat it  ;)
Frankly speaking, I thought that it is was not possible as well.

Jumpy

Only Callthis passes along as (default) first argument a reference to the calling shape.

The others (RUNMACRO, RUNADDON or RUNADDONWARGS) don't do this.

I just read that RUNMACRO could work, too, because you can pass along the project as second arg, too. Didn't knew that, because I always thought, that you need a reference to the project with RUNMACRO, but the following link proved me wrong:

http://msdn.microsoft.com/en-us/library/ms425549(v=office.12).aspx



But RUNADDON or RUNADDONWARGS  definitley can't call to code in the stencil without a reference.

Jumpy