Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Templates/Add-ins (Word 2000)

    I'm so confused...I want to create a master template that several other templates are based on so that I only have to edit/change macros in the master template. I have created a link so it loads this master template as an add in. Now I am ready to create the additional templates. How do I create them so when I change the macros in the master template, they are changed in the other templates?

    I hope you understand what I am asking...

  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: Templates/Add-ins (Word 2000)

    Well, one approach would be: do not copy the macros from the master template into the individual document templates. Instead, call the macros in the master template to do the work. So there would just be a stub in the template macro that passes whatever objects the master macro needs:

    Sub DoAComplexThing()
    Call ComplexThing(ActiveDocument)
    End Sub

    Sub ComplexThing(doc As Document)
    'Code to do something to doc TBD
    End Sub

    I guess the better practice would be to make the master macros functions and return an indication of whether they encountered a problem.

    Sub DoAComplexThing()
    If ComplexThing(ActiveDocument) = True then
    MsgBox "It worked!"
    Else
    MsgBox "No dice"
    End If
    End Sub

    Function ComplexThing(doc As Document) as Boolean
    'Code to do something to doc TBD
    'If successful:
    ComplexThing = True
    End Sub

    Is this roughly along the lines of what you were thinking?

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Templates/Add-ins (Word 2000)

    I think I understand what you're hoping to do, and if it's the same thing I was hoping to do, I don't think it's possible - at least not easy. I was under the impression that it might be possible to create a master, from which other templates "inherit" and that changes to the master would cascade down through all the child templates based on it. I think the suggestions that Stuart made are an example of "forcing" this kind of behaviour.

    But generally, the child template features become "hard coded copy" from, rather than links to, the parent template on which the child is based. What I had hoped to do was to have all the common features (graphic letterhead etc.) in the master, then generate a family of relatively lightweight children (letter, invoice, account etc.) from this. When I looked at the template sizes though, I found that any linking efforts I made didn't "stick" and the links were broken when I saved the children. The latter behaved as independent templates - in other words with no working connection to (changes to) the master at all and no savings in terms of template sizes.

    Now I'll bet (in fact hope) that one of the experts proves me wrong <img src=/S/grin.gif border=0 alt=grin width=15 height=15>.

    Alan

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Templates/Add-ins (Word 2000)

    Templates don't work that way.

    You would need to do all your coding in a single template, and put "wrapper" code in the other templates.
    Each of the wrapper macros would invoke code in the master template.

    However, you may be able to achieve the same effect by putting all your code in a Global template in Word's StartUp directory.
    All macros would then be available for use with any document. I expect that this what you are really after.

  5. #5
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Templates/Add-ins (Word 2000)

    Actually, referencing the macros in a master template is what will work best for this application. We have several different account, each with their own master template, so we do not want to make these global templates. I am starting word, loading the master template as an add-in, so referencing the macros in the master template should work. The macros are all accessed via a toolbar which loads with the master template.

    Next question, how to determine the entire pathname of a macro...If the document name is HMHMaster.dot and the macros are in Template Project, Modules, New Macros, is the name: HMHMaster.TemplateProject.Modules.NewMacros.AutoEx ec? I would want to reference the entire pathname in the master template so when the toolbar loads, the document is not looking for the macros in "ThisDocument", correct?

    Thanks again!

  6. #6
    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: Templates/Add-ins (Word 2000)

    One way to figure out the name you need is simply to try it out with an interactively created toolbar.

    Then you can use VBA's Immediate Window to query the new control's properties. For a sub procedure added from my global template jTools3.dot, I got this:

    ?commandbars("custom 1").Controls(1).Caption
    jTools3.MiscTools.ShrinkPic

    ?commandbars("custom 1").Controls(1).OnAction
    MiscTools.ShrinkPic

    Hope this helps. (I didn't open the template to see whether it was declared as "Public"; that might matter.)

Posting Permissions

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