For example:
Code:
Sub GetDocumentStats()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String
Dim strList As String, i As Long, wdDoc As Document
strDocNm = ActiveDocument.FullName: strFolder = "C:\Sam-Documents\VBA-Word"
strFile = Dir(strFolder & "\*.docx", vbNormal)
While strFile <> ""
If strFolder & "\" & strFile <> strDocNm Then
i = i + 1
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
With wdDoc
With .Range.Find
.Text = strFnd
.MatchCase = False
.MatchAllWordForms = False
.MatchWholeWord = False
.Execute
If .Found = True Then strList = strList & vbCr & strFile
End With
.Close SaveChanges:=False
End With
End If
' Let Word do its housekeeping
DoEvents
strFile = Dir()
Wend
Set wdDoc = Nothing
MsgBox i & " files processed." & vbCr & "Matches with " & strFnd & " found in:" & strList, vbOKOnly
Application.ScreenUpdating = True
End Sub