Results 1 to 5 of 5

Thread: Attach template refused with error 5947 Could not change document template

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4

    I think I got it

    I think I nailed it:
    1) Create a dotm template
    2) Add an "openclose" module containing AutoOpen and AutoClose. Whatever goes in there will be executed by a document based on the template
    2) Add a "TemplateSpecific" module containing an AutoNew module. This is executed when a new document is created based on template. All it does is copying the "openclose" module to the newly created document project
    3) Because the AutoOpen and AutoClose routines are initially only in the template project, they will get executed although most of the code is meant for the document and not the template. However:
    a) AutoClose: if not the .dotm template: remove the template attachment (this avoids MISSING references upon opening, but also lacks a few libraries that must be added programmatically upon AutoOpen)
    b) AutoOpen: if not the .dotm template: attach to template known to exist in a predetermined location (different on any pc, but pointed to through an environment variable that can be set differently for each pc). This requires adding the Scripting library programmatically and using the FileSystemObject through late binding

    I enclose the basics needed in the attached .dotm (that I had to rename .docm to be accepted for upload). A lot of "Debug.Print" statements have been left/inserted to show the steps taken.
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

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