Hello,
I found an almost perfect code for what I need here I need to search 1000's of documents for 1-800 phone numbers ( 5 different ones)and change them all to 1 new one. How can I modify this code with either wild cards or by placing all of the old phone numbers and have it search for them and if found change
Thanks
I found an almost perfect code for what I need here I need to search 1000's of documents for 1-800 phone numbers ( 5 different ones)and change them all to 1 new one. How can I modify this code with either wild cards or by placing all of the old phone numbers and have it search for them and if found change
Code:
Dim fs, fil, fldr, strPath
Dim wd
Set fs = CreateObject("Scripting.FileSystemObject")
strPath = InputBox("Enter Path of folder", "Find File")
If strPath = "" Or fs.FolderExists(strPath) = False Then
MsgBox "Not a valid folder Path.", 64
'WScript.Quit
End If
Set wd = CreateObject("Word.Application")
wd.Visible = True
Set fldr = fs.GetFolder(strPath)
For Each fil In fldr.Files
' If fil.Type = "Microsoft Word Document" Then
If fil.Type = "Microsoft Word 97 - 2003 Document" Then
wd.Documents.Open fil.Path
wd.Selection.Find.ClearFormatting
With wd.Selection.Find
.Text = "1-800-111-1111"
.Forward = True
End With
wd.Selection.Find.Execute
If wd.Selection.Find.Found Then
wd.Selection.Range = "1-800-222-2222"
End If
wd.Documents.Close
End If
Next
wd.Quit