Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
Can anyone halp me with this script?
I need to change the "attached template" path in many files in many directories & concluded that this was the best option. I have however come unstuck with my limited scripting ability!
Here's what I have so far;
Option Explicit
Sub Remap()
Dim strFilePath
Dim strPath
Dim intCounter
Dim strFileName
Dim OldServer
Dim NewServer
Dim nServer
Dim objDoc
Dim objTemplate
Dim dlgTemplateOldServer = "<\\Server\Templates>"
NewServer = "<K:\Templates>"
nServer = Len(OldServer)
strFilePath = InputBox("What is the folder location that you want to use?")
If Right(strFilePath, 1) <> "\" Then strFilePath = strFilePath & "\"
strFileName = (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 = NewServer & Mid(strPath, (nserver + 1))
End If
strFileName = Dir()
objDoc.Save
objDoc.Close
Loop
Set objDoc = Nothing
Set objTemplate = Nothing
Set dlgTemplate = NothingEnd Sub
Any help most appreciated.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |