Word VBA Script to modify all documents in folder & all subfolders
Posted on 2004-11-11
Hi - I received help on this forum a while ago when someone provided code to open all templates in a specified folder and make a change, save changes, close then process the next item. I've pasted that code below but what I now need it for the script to process the starting folder then and sub folders, and subfolder within those etc etc. Any help on this would be greatly appreciated.
' Display the names in C:\ that represent directories.
MyPath = "c:\templates\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
' Use bitwise comparison to make sure Document is a template
If Right(MyName, 4) = ".dot" Then
Documents.Open MyPath & MyName
'Do things to template here*****************
End If ' it represents a directory.
MyName = Dir ' Get next entry.