Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Mar 2002
    Location
    Sunnvyale, California, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Copy macros from template (Word 2000)

    Hi,
    I've created a template that contains macros invoked from menus and macrobuttons. When the template is double clicked by a user to create a new document, I would like the macros to be copied into the new document. It looks like documents.add doesn't have a switch to do it either. Any way to do this?

    I found this problem by creating a document from the template and then emailing it to work where the macrobuttons didn't work. The new document appears to keep track of the template location (and therefore macros) when you work with the document on the same computer that it was created on but looses track if the path (?) changes?

    Thanks,
    Eric

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Copy macros from template (Word 2000)

    You don't want to copy the macros into the document itself. This makes the actual documents too big and also creates an administration nightmare if you want to change code.

    What you need to do is save a copy of the template and put it on the other machine in one of four possible locations
    1. The same directory as the file
    2. The User Templates directory (Check what this is under Tools > Options > File Locations)
    3. The Workgroup Templates directory (Check what this is under Tools > Options > File Locations)
    4. The same directory path for the attached template as shown in Tools > Templates and Add-ins

    If a template with the same name exists in any one of these locations then Word will find it when the file is opened and you will have full access to all your template goodies.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Copy macros from template (Word 2000)

    One of the purposes of templates in Word is to provide a central storage place for macros, menu and toolbar customizations etc. If you modify a macro or menu or toolbar in a template, all documents based on the template will use the new version. If you would store them in the documents themselves (as is the case in Excel), maintenance becomes very difficult. Plus, document size increases, the user gets warned that the document contains macros, and it won't work at all for AutoText entries. Those can only be stored in templates, not in documents.

    One way to make templates available in a network is to put them in a network folder in which all users have read permission. By pointing the Workgroup Templates path of all users to this folder, the templates will be made available.

  4. #4
    Lounger
    Join Date
    Mar 2002
    Location
    Sunnvyale, California, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy macros from template (Word 2000)

    Hi,
    Thanks for your responses, they are in agreement with my preferences and is what I am doing now (network location). We do have a fair number of people who work from laptops, they might start the document from the network template and then take it on the road to do updates while on the airplane, etc. Perhaps I could have an AutoOpen macro in the template that would compare a local copy against a network copy, update the local copy if necessary so they always had access to the macros? Only way I can think of for solving the problem.

    Thanks,
    Eric

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Copy macros from template (Word 2000)

    I don't think you'll be able to have the template replace itself - it will be in use if you try to do so. But you could probably put a routine in a global template that checks the local version of document templatesto the version on the network, and update the local version if necessary.

  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: Copy macros from template (Word 2000)

    If you do replace the template, you might let them know you will be doing that so they don't add customizations. I distributed a template with some pre-defined AutoText integrated with its functionality. It later occurred to me that the users might add their own AutoText to the template, and it would be impolite of me to delete it. Unfortunately, it wasn't practical to be polite in that case, so a warning had to do.

  7. #7
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Copy macros from template (Word 2000)

    I would set the update template macro as part of the logon script. If you leave it until the user opens the Word document then you will run into the problem of the file already being open so the attached template can't be updated as it is already locked. This also gives the user the updated template, whether or not they used Word during their time on the network.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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