Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Explicit
Sub yadda()
Dim j As Long
Dim fs As FileSearch
Dim SearchFor As String
Dim MyReplace As String
SearchFor = "The quick brown fox jumped over the moon."
MyReplace = "whatever"
Set fs = Application.FileSearch
With fs
[COLOR=red] ' collect ONLY files that contain
' the SearchFor string[/color red]
.FileType = msoFileTypeWordDocuments
.LookIn = "c:\zzz\test\"
.SearchSubFolders = True
.TextOrProperty = SearchFor
[COLOR=red]' if there are any[/color red]
If .Execute > 0 Then
[COLOR=red]' interate through all of them[/color red]
For j = 1 To .FoundFiles.Count
[COLOR=red]' open each one[/color red]
Documents.Open FileName:=.FoundFiles(j)
[COLOR=red]' and do the Find/Replace[/color red]
With Selection.Find
.Text = SearchFor
.Replacement.Text = MyReplace
.Execute Replace:=wdReplaceAll
End With
[COLOR=red]' save and close[/color red]
ActiveDocument.Save
ActiveDocument.Close
[COLOR=red]' action next file[/color red]
Next j
End If
End With
End Sub