Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Location
    Copenhagen, Denmark
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Calling procedure in another template (XP)

    Greetings

    I never really had to use this before, so excuse me for asking a silly question. I have two global templates - and I need to execute a specific procedure in one template from the other template. The procedure name is "SetBakker" and it is located in the module "PrintHandling" in the global template "KAnormal.dot" - I have tried a few suggestions:

    Application.Run MacroName:="SetBakker" (the code does not execute - when I step through the calling code it simply skips the statement - or so it seems)
    Call SetBakker (compile error: Sub or Function not defined)
    [KAnormal.dot].[PrintHandling].SetBakker (compile error: External name not defined)

    Could anyone please enlighten me?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Calling procedure in another template (XP)

    This is a common topic of discussion on the VB/VBA board, so I am cross-referencing posts over there. (E.g., see <!post=Post #182610,182610>Post #182610<!/post>, or this thread or this other one).

    To address your specific questions, the online help for Word 2000 says:
    <hr>Application.Run MacroName

    MacroName Required String. The name of the macro. Can be any combination of template, module, and macro name. For example, the following statements are all valid.

    Application.Run "Normal.Module1.MAIN"
    Application.Run "MyProject.MyModule.MyProcedure"
    Application.Run "'My Document.doc'!ThisModule.ThisProcedure"<hr>
    In my experience with global templates, sometimes the dotted notation is necessary and sometimes it isn't. Perhaps it's the way that the procedure is declared (e.g., Sub vs. Public ?).

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Location
    Copenhagen, Denmark
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Calling procedure in another template (XP)

    Thanx Jscher

    I tried the "fully qualified" syntax - and it didn't worf at first. It just skipped the line. But this was when the global template (that I tried to address) wasn't loaded as a global template, but loaded as a document (next to the template that tried to call a procedure in it. I tried to load the global template as in real life and the code executed without any problems - hmmmm - can't see why it didn't execute before, but as long as it works ....

    Thanx again
    Jaspar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •