Add Method (PropertyTests Collection) Example
This example adds two property tests to the search criteria. The first test is that the files must be Word documents, and the second test is that they must have been modified between January 1, 1996, and June 30, 1996. The example also displays a message box that shows the total number of files found, if any, and the name of each file found.
Set fs = Application.FileSearch
fs.NewSearch
With fs.PropertyTests
.Add Name:="Files of Type", _
Condition:=msoConditionFileTypeWordDocuments, _
Connector:=msoConnectorOr
.Add Name:="Last Modified", _
Condition:=msoConditionAnytimeBetween, _
Value:="1/1/98", SecondValue:="6/30/98", _
Connector:=msoConnectorAnd
End With
If fs.Execute() > 0 Then
For i = 1 To fs.FoundFiles.Count
strFound = strFound & fs.FoundFiles(i) & vbCrLf
Next i
MsgBox "Search found the following " _
& fs.FoundFiles.Count & _
" file(s):" & vbCrLf & strFound
Else
MsgBox "There were no files found."
End If