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
I think you can't call a macro in a stencil from shape sheet directly.
Why did you think you could do that?
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
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
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
Don't sweat it ;)
Frankly speaking, I thought that it is was not possible as well.
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
Browser ID: smf
(is_webkit)
Templates: 1:
Printpage (default).
Sub templates: 4:
init,
print_above,
main,
print_below.
Language files: 1:
index+Modifications.english (default).
Style sheets: 0:
.
Hooks called: 59 (
showintegrate_autoload, cache_get_data, integrate_pre_load, integrate_load_session, integrate_verify_user, cache_get_data, integrate_user_info, integrate_load_board, cache_get_data, integrate_board_info, cache_get_data, integrate_allowed_to_general, integrate_pre_load_theme, cache_get_data, integrate_allowed_to_general, integrate_simple_actions, integrate_allowed_to_general, integrate_load_theme, integrate_pre_log_stats, cache_get_data, integrate_actions, integrate_pre_parsebbc, integrate_bbc_codes, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_menu_buttons, integrate_current_action, integrate_theme_context, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general)
Files included: 25 - 925KB. (
show/home/iw0lkfe3x6cq/public_html/vgforum/index.php, /home/iw0lkfe3x6cq/public_html/vgforum/Settings.php, /home/iw0lkfe3x6cq/public_html/vgforum/cache/db_last_error.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/QueryString.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Auth.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Errors.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Load.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Security.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Compat.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Db-mysql.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApi.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApiInterface.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/APIs/FileBased.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Charset.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/Metadata.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/QuickCheck.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Session.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Logging.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Class-BrowserDetect.php, (Current Theme)/languages/index.english.php, (Current Theme)/languages/Modifications.english.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Printpage.php, (Current Theme)/Printpage.template.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/CaseUpper.php)
Memory used: 762KB.
Tokens:
post-login.
Cache hits: 7: 0.00116s for 22,302 bytes (
showget modSettings: 0.00039s - 19983 bytes, get known_languages: 0.00026s - 1277 bytes, get board_parents-0: 0.00012s - 2 bytes, get permissions:-1: 0.00009s - 50 bytes, get theme_settings-1: 0.00012s - 980 bytes, get log_online-update: 0.00013s - 10 bytes, get menu_buttons--1-english: 0.00005s - 0 bytes)
Cache misses: 1: (
showget menu_buttons--1-english)
Queries used: 9.
[Show Queries]