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.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
If you have a template stored on disk, you can open it and make changes to it just as you do other documents. This tip ...
Discover MoreConfused about where to store your templates in Word so that they are available when using the program? This tip ...
Discover MoreIf you've opened a document in Word, that document has a template attached to it. This tip looks at what those templates ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments