Changing multiple word document templates

M

Malcz86

I have several thousand word documents that need template paths changing I've
done a bit of googling and found the below script,

Sub Test()

Dim strFilePath As String
Dim strPath As String
Dim intCounter As Integer
Dim strFileName As String
Dim OldServer As String
Dim objDoc As Document
Dim objTemplate As Template
Dim dlgTemplate As Dialog
Dim nServer As Integer

'hardcode the name of the old server.

OldServer = "{enter the name of the Old Server}"
nServer = Len(OldServer)

strFilePath = InputBox("What is the folder location that you want
to use?")

If Right(strFilePath, 1) <> "\" Then strFilePath = strFilePath & "\"

strFileName = Dir(strFilePath & "*.doc")

Do While strFileName <> ""

Set objDoc = Documents.Open(strFilePath & strFileName)

Set objTemplate = objDoc.AttachedTemplate

Set dlgTemplate = Dialogs(wdDialogToolsTemplates)

strPath = dlgTemplate.Template

If LCase(Left(strPath, nServer)) = LCase(OldServer) Then

objDoc.AttachedTemplate = NormalTemplate

End If

strFileName = Dir()

objDoc.Save

objDoc.Close

Loop

Set objDoc = Nothing

Set objTemplate = Nothing

Set dlgTemplate = Nothing

End Sub

Problem is it doesn't work????

I assume I'm meant to put something in here,

OldServer = "{enter the name of the Old Server}"
nServer = Len(OldServer)

But what????
 
Top