Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Nov 2006
    Location
    Oslo, Oslo, Norway
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Remove attached template when opening existing doc (Word 2003)

    We have loads of documents based on different templates in our company. After changing our servers (and thus the server names) existing documents took a looong time to open. Looking into this lounge gave me the answer to our problems: the attached template for the document was pointing to the old, obsolete UNC path.

    Our installation of Word has a global path loaded when starting Word. Can I create a macro that, when opening an existing document, removes the attached template to the document and sets it to the normal template?

    I know the command - ActiveDocument.AttachedTemplate = NormalTemplate - but how to embed it som it runs on every document that is opened?

    christian, Oslo

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

    Re: Remove attached template when opening existing doc (Word 2003)

    Welcome to Woody's Lounge!

    You could put a macro named AutoOpen in Normal.dot. It will be run automatically when a document (based on any template, not just on normal.dot) is opened:

    Sub AutoOpen()
    ActiveDocument.AttachedTemplate = NormalTemplate
    End Sub

  3. The Following User Says Thank You to HansV For This Useful Post:

    viren04 (2014-05-31)

  4. #3
    New Lounger
    Join Date
    Nov 2006
    Location
    Oslo, Oslo, Norway
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Remove attached template when opening existing doc (Word 2003)

    Thanks, Hans,
    I'm an old fan of Woody since the 'Hackers Guide to Word 6.0' - at the time a fantastic book.

    To the case - thanks for the tip. I guess this AutoOpen macro will also work if it's placed in a global template defined in the startup-path, correct?

    Regards,
    Christian

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

    Re: Remove attached template when opening existing doc (Word 2003)

    No, AutoOpen doesn't run in a global template. If you want to use a global template, you must use application-level event code in a class moduie, and initialize an application variable in the AutoExec macro (the only macro that will run automatically in a global template). I have attached a sample template (zipped), meant to be installed in Word's startup location.
    Attached Files Attached Files

  6. The Following User Says Thank You to HansV For This Useful Post:

    viren04 (2014-05-31)

Posting Permissions

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