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

Removing All Macros

Macros are stored as part of a workbook so that they are always available when you have the workbook open. If you want to ...

Discover More

Increasing Envelope Address Lines

Envelopes in Word are created through the use of styles that define specific elements of the envelope, such as return ...

Discover More

Smart Quotes are Incorrectly Replaced

Not able to replace smart quotes as you want? Here are some ways that you can be sure that every smart quote is changed, ...

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)

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

What Changes Did I Make In that Template?

When you make changes that affect a template, Word usually asks you if you want to save those changes when you exit the ...

Discover More

Best Way to Create a Document Template

Templates are the basis of creating consistent documents that permit fast and easy formatting. What is the best way to ...

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 one less than 9?

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.