Using Documents after a Server Move

Written by Allen Wyatt (last updated July 16, 2022)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021


Francisco's company recently moved their shared templates from one server to another. Now, they can no longer open any documents that were created in the past that referenced the old template location. When they try to open the document they get the Word splash screen and then it gets stuck on connecting to the old location where the templates used to be. Francisco wonders how they can use their old documents if they cannot even open them.

There are a couple of approaches you can use for a problem such as this. If the template location on the old server was accessed through a mapped drive in Windows, then you may be able to simply re-map the drive to the new location. For instance, if the old template location was mapped to drive Z:, just break the mapping connection in Windows and re-map drive Z: to the new server location. If you are able to do this, then your Word documents should just open directly, as the location mapping is handled completely by Windows.

If, however, your templates were accessed using a UNC path instead of a mapped drive, then you may want to see if your IT folks can either set up the older server until you can open your documents and change the template location within the documents, or perhaps they can create an "alias" on the new server that looks, to your connected machines, as if the old server's path is now on the new server. (Setting up an alias is similar to mapping a drive in Windows, except it is done on the actual server.)

If you want, you can try using a macro to access the documents and change the attached template to something that is accessible from the computer. The following can be thought of as a good starting place for such a macro.

Sub FixDocs()
    Dim sDocRoot As String
    Dim sNewTemplate As String
    Dim sUserTemplates As String
    Dim sWorkgroupTemplates As String
    Dim sFile As String
    Dim sAbsFile As String
    Dim sAbsTemplate As String
    Dim sOldTemplate As String
    Dim d As Document
    Dim sMsg As String
    Dim sTemp As String

    sDocRoot = "c:\path\to\documents\"
    sNewTemplate = "c:\absolute\location\of\new\template\Normal.dotm"

    With Application.Options
        sWorkgroupTemplates = .DefaultFilePath(wdWorkgroupTemplatesPath)
        sUserTemplates = .DefaultFilePath(wdUserTemplatesPath)
    End With

    sFile = Dir(sDocRoot & "*.docx")

    Do While Len(sFile) > 0
        sAbsFile = sDocRoot & sFile
        Set d = Documents.Open(sAbsFile)
        sOldTemplate = d.AttachedTemplate

        sMsg = sMsg & "Document Name          = " & sFile & vbCrLf
        sMsg = sMsg & "Absolute Document Name = " & sAbsFile & vbCrLf
        sMsg = sMsg & "Attached Template      = " & sOldTemplate & vbCrLf

        sTemp = "Old template (" & sOldTemplate & ") found in "
        sAbsTemplate = sWorkgroupTemplates & "\" & sOldTemplate
        If IsFile(sAbsTemplate) Then
            sTemp = sTemp & "workgroups template directory"
        Else
            sAbsTemplate = sUserTemplates & "\" & sOldTemplate
            If IsFile(sAbsTemplate) Then
                sTemp = sTemp & "user templates directory"
            Else
                sTemp = "Old template (" & sOldTemplate & ") not found"
            End If
        End If
        sMsg = sMsg & sTemp & vbCrLf

        If sAbsTemplate <> sNewTemplate Then
            d.AttachedTemplate = sNewTemplate
            d.Close SaveChanges:=wdSaveChanges
            sMsg = sMsg & "Document updated" & vbCrLf
        Else
            d.Close SaveChanges:=wdDoNotSaveChanges
            sMsg = sMsg & "Document not updated" & vbCrLf
        End If

        Set d = Nothing
        sMsg = sMsg & vbCrLf
        sFile = Dir
    Loop
    MsgBox sMsg
End Sub
Function IsFile(ByRef fName As String) As Boolean
    'Returns TRUE if the provided name points to an existing file
    'Returns FALSE if not existing, or if it's a folder

    On Error Resume Next
    IsFile = ((GetAttr(fName) And vbDirectory) <> vbDirectory)
End Function

To use the macro, you'll want to change the path assigned to sDocRoot; it should be the directory (with the trailing backslash) where your documents are located. Then, change sNewTemplate so it is the complete path to the new template you want to use.

The macro steps through each document in the sDocRoot directory, opens it, checks if the old template is in either the workgroup templates or user templates directory, and then changes the attached template to the new template if it wasn't already attached.

One thing you'll definitely want to do before using this macro is to backup all the documents you want to process. It may take a bit of trial and error to make sure that everything gets changed to what you need, but the "audit trail" that is compiled in the sMsg variable will be helpful in that regard. The macro displays the results when completed, but you can always change the macro to save the results in a brand new document so you can have a permanent record of what was done.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12927) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Indent and Justify Command

WordPerfect users are familiar with the F4 command, which indents and justifies a paragraph. Word does not have an ...

Discover More

Changing How Links are Activated

Got some active links in your document? Do you want to have them activated when you click on them, or do you want to ...

Discover More

Modifying Axis Scale Labels

You want your chart to display information as clearly and succinctly as possible. Modifying the labels used to indicate ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Making Templates Available to Word

Confused about where to store your templates in Word so that they are available when using the program? This tip ...

Discover More

Listing the Settings in a Template

Templates allow you to define and collect many formatting settings that control how your documents appear. Getting a ...

Discover More

Inconsistent Prompting to Save Normal Template Changes

You can configure Word to notify you when it is about to save updates to the Normal template. There may be some ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.