Hello everyone.
I have the following macro to batch change the templates of all word documents in a folder. However, there are several subdirectories within that folder as well, so I would like to have it check those as well. Can anyone modify it so that it does that?
Code:
Sub ChangeTemplates()
Dim strDocPath As String
Dim strTemplateB As String
Dim strCurDoc As String
Dim docCurDoc As Document
' set document folder path and template strings
strDocPath = "C:\Users\servicedesk\Desktop\Test\"
strTemplateB = "C:\Users\servicedesk\Desktop\Blanco.dotx"
' get first doc - only time need to provide file spec
strCurDoc = Dir(strDocPath & "*.doc")
' ready to loop (for as long as file found)
Do While strCurDoc <> ""
' open file
Set docCurDoc = Documents.Open(FileName:=strDocPath & strCurDoc)
' change the template
docCurDoc.AttachedTemplate = strTemplateB
' save and close
docCurDoc.Close wdSaveChanges
' get next file name
strCurDoc = Dir
Loop
MsgBox "Finished"
End Sub