Templates and add-ins problem

H

HWhite

I have thousands of Word documents on a file server that are taking too long
to load when opening in Word 2003. After reading through the discussion
groups, I've confirmed that the document template listed in the "templates
and add-ins" field of each document are pointing to a location that no longer
exists, and was on a network share. It is taking our users a minute to two
minutes to open each of these documents.

I need a solution that does one of the following...

1. Updates each document with the new location of the template.
(\\oldserver\templates\templatename.dot to
\\newserver\templates\templatename.dot)
2. Erases the entry in the templates and add-ins field altogether (will
this cause issues?)
3. Reduce or eliminate the time-out setting for searching for the template.

I really need a solution to this quickly, so hopefully somebody out there
can help me. Also, I don't know VBA, so if your solution involves running
scripts, I'll need a little extra hand-holding.

Thanks very much.
 
G

Graham Mayor

Provided the document template names are the same in the old and new
template folders (no sub folders for example) the following macro *should*
change the template folder location for files in a selected folder.

Change the path to the actual path of the new template folder in the line
sNewPath = "\\newserver\templates\"
Note that if a template of the same name as the original template is not
present in that folder no change is made.

The macro should not affect those files based on normal.dot. However while
tests on a standalone machine are all very well, introducing your network
into the mix may not result in the desired outcome. However feel free to
test it on copies of some of your documents before running it on the live
files.

http://www.gmayor.com/installing_macro.htm

Sub ChangeTemplateFolder()
Dim iFld As Integer
Dim strCodes As String
Dim FirstLoop As Boolean
Dim strFileName As String
Dim strPath As String
Dim oDoc As Document
Dim sTemplate As Template
Dim sNewPath As String
Dim i As Long

sNewPath = "\\newserver\templates\"
With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
strPath = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With

If Documents.Count > 0 Then
Documents.Close savechanges:=wdPromptToSaveChanges
End If
FirstLoop = True
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFileName = Dir$(strPath & "*.doc")

While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)

Set sTemplate = ActiveDocument.AttachedTemplate
On Error Resume Next
With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = sNewPath & sTemplate.Name
End With
oDoc.Close savechanges:=wdSaveChanges
Set oDoc = Nothing
GetNextDoc:
strFileName = Dir$()
Wend
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top