• Document attached to wrong template

    • This topic has 7 replies, 4 voices, and was last updated 24 years ago.
    Author
    Topic
    #355417

    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?

    Viewing 1 reply thread
    Author
    Replies
    • #524159

      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

      • #524256

        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

        • #524265

          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.

        • #524389

          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

        • #524480

          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

          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
          
    • #524226

      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 How to enable the spellchecker in a protected document 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.

      • #524229

        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.) crazy

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

    Viewing 1 reply thread
    Reply To: Document attached to wrong template

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: