Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Location
    Omaha, Nebraska, USA
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Document attached to wrong template

    Our organization is moving from NT/Office 97 to Win 2000/Office 2000. We have several Word 97 Templates with embedded macros. The problem that we are having is that the macros do not work in documents started under the NT/97 systems when they are opened on the Win 2000/Office 2000 systems. This is because the attached template path is no longer correct because the server name and share where the documents are stored has changed. TechNet article Q220502 indicates that Word will look for the attached template in:

    1 - The specified location
    2 - The User Templates location
    3 - The Workgroup templates loaction
    4 - The installed templates location

    We have tried putting the template in the User Templates Location and in the Workgroup Templates location but Word still does not find it. Both the Template and the document are Protected. Can Word not change the attached template in a Protected document or does anyone have any ideas as to why Word is not finding the template?

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Document attached to wrong template

    I haven't read the TechNet article, but it may be a little misleading: at least on network installations, once the attached template is moved to different location, the document based on it can no longer find it.

    It doesn't matter if the workgroup templates pointer is changed in Tools>Options>File Locations (that will only affect new documents created going forward). (And it has nothing to do with the documents being protected.)

    Efficiently reattaching existing documents to their templates requires a macro; it can get pretty complicated, depending on how many templates are involved.

    I have code for doing this, but it was tailored to a specific network and group of templates.

    If you post back with little more detail (such as how many templates, a representative old path and a representative new path), it might be possible to adapt some of the code I've got to your situation.

    Gary

  3. #3
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Document attached to wrong template

    Have you tried manually reattaching the documents? This may require unprotecting and reprotecting them. Do this with copies until you get the process down right. Reprotecting them without resetting all of your fields requires use of VBA. See <A target="_blank" HREF=http://www.mvps.org/word/FAQs/MacrosVBA/SpellcheckProtectDoc.htm>How to enable the spellchecker in a protected document</A> for the VBA code involved in that.

    Attaching a template is done with Tools => Templates and Add-Ins...

    Once the document is reattached and saved it will remain attached.
    Charles Kyle Kenyon
    Madison, Wisconsin

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Document attached to wrong template

    Although technically the templates can be reattached manually, this doesn't turn out to be a practical option for most organizations, particularly if there are many users and a very large number of documents.

    Imagine trying to distribute instructions to all users on how to unprotect the form, go to Templates and Add-Ins and browse to the new template location, and finally, run a macro to reprotect while saving the form fields' contents. (And now, repeat for every document you open.) <img src=/S/crazy.gif border=0 alt=crazy width=15 height=15>

    This is a situation where an automated solution is the only way to go.

  5. #5
    New Lounger
    Join Date
    Mar 2002
    Location
    Omaha, Nebraska, USA
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Document attached to wrong template

    We have around 300 templates, a few of which are very heavily used.

    An example of an old path would be:

    "SENECNTS01appsFCSM TemplatesFCS Forms6306 Loan Analysis and Decision Report.dot"

    The new path would be something like this:

    SENECAKSS01AppsFCSA TemplatesFCSA Forms6306 Loan Analysis and Decision Report.dot

    Thanks,

    Brian

  6. #6
    New Lounger
    Join Date
    Apr 2001
    Location
    Germany, Hamburg
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Document attached to wrong template

    Just a little tip for your conversion:
    Avoid absolute pathnames in applications as much as possible because of all these ramifications. Ask your Win2K administrators to set up a DFS filesystem with logical mountpoints hiding the physical location of the templates.

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Document attached to wrong template

    Brian,

    Just a quick note to say I haven't forgotten about this one - I sketched out some code on paper but haven't had the spare minutes to type it up and test it.

    I'll try to post something usable, hopefully in the next day or so, so watch this space!

    Gary

  8. #8
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Working example

    Set out below is a working example of code that will do this. Although it would be inefficient to have to hard-code in the new and old paths for hundreds of templates, if you're doing it for just a few, it's easy enough.

    Another issue is deployment of this kind of code - there are two options:
    User-activated, and automatic.

    For user-activated, this can be made available in a global template, which can either be in the Startup directory or loaded as an add-in as needed. You would need to attach this macro to a button which the user could click to run the macro, whenever they felt that the reattach template procedure needed to be done.

    To make it automatic, you'd need to put it into something like an AutoOpen procedure in a global template. This could possibly raise issues if there happen to be AutoOpen procedures in any of the your "attached" templates, as the more local procedure is going to take precedence over the one in the global. In this case, another alternative would be to put a call to the UpdatePath procedure, into the AutoOpen procedures in every template, along the lines of:

    Application.Run MacroName:="UpdatePath".

    Hope this helps,
    Gary

    <pre>Public Sub UpdatePath()
    'Gary Frieder April 2001
    '(thanks to John Fitzgerald)
    Dim strTemplatePath As String
    Const OLDPATH1 As String = _
    "SENECNTS01appsFCSM TemplatesFCS Forms6306 Loan Analysis and Decision Report.dot"
    Const NEWPATH1 As String = _
    "SENECAKSS01AppsFCSA TemplatesFCSA Forms6306 Loan Analysis and Decision Report.dot"
    Dim diaTemplates As Dialog

    On Error GoTo UpdatePath_Err
    'test to ensure not a .dot and exit sub if it is
    If Right(ActiveDocument.Name, 4) = ".dot" Then
    Exit Sub
    End If

    Set diaTemplates = Dialogs(wdDialogToolsTemplates)
    strTemplatePath = diaTemplates.Template

    'Test to see if new path is already in place:
    If Left(strTemplatePath, 23) <> "SENECAKSS01AppsFCSA" Then
    '(or alternatively
    'If Left(strTemplatePath, 23) <> Left(NEWPATH1, 23) Then
    'If not, test OldPath and reassign accordingly
    Select Case strTemplatePath
    Case OLDPATH1
    'this part could be done via a called function:
    ActiveDocument.AttachedTemplate = NEWPATH1
    ActiveDocument.UpdateStylesOnOpen = False
    'Case OLDPATH2 etc....
    Case "Normal"
    Exit Sub
    Case Else
    MsgBox "Template could not be reattached automatically."
    End Select
    End If

    Exit Sub
    UpdatePath_Err:
    MsgBox "Template could not be reattached automatically."

    End Sub
    </pre>


Posting Permissions

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