Sub ReportGreenDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document, StrRpt As String
strDocNm = ActiveDocument.FullName
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
If strFolder & "\" & strFile <> strDocNm Then
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, ReadOnly:=True, Visible:=False)
With wdDoc
With .Range.Find
.ClearFormatting
.Text = ""
.Font.ColorIndex = wdGreen
With .Replacement
.ClearFormatting
.Text = ""
End With
.Forward = True
.Wrap = wdFindContinue
.Format = True
.Execute
If .Found = True Then StrRpt = StrRpt & vbCr & wdDoc.Name
End With
.Close SaveChanges:=False
End With
End If
strFile = Dir()
Wend
Set wdDoc = Nothing
If StrRpt <> "" Then
MsgBox "The following files with green body text were found:" & vbCr & StrRpt
Else
MsgBox "No files with green body text were found."
End If
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function