FileSearch![]() ![]() ![]() |
A collection of PropertyTest objects that represent all the search criteria of a file search. Search criteria are listed in the Advanced Find dialog box (File menu, Open command, Advanced Find button).
Use the PropertyTests property to return the PropertyTests collection. The following example displays the number of advanced-find search criteria that will be used for one file search.
Application.FileSearch.PropertyTests.Count
Use the Add method to add a new PropertyTest object to the PropertyTests collection. The following example adds two property tests to the search criteria. The first criterion specifies that the files that are found can be of any file type, and the second criterion specifies that these files must have been modified between January 1, 1996, and June 30, 1996. The example displays the number of files found and displays the name of each file in a message box.
Set fs = Application.FileSearch
fs.NewSearch
With fs.PropertyTests
.Add Name:="Files of Type", _
Condition:=msoConditionFileTypeAllFiles, _
Connector:=msoConnectorOr
.Add Name:="Last Modified", _
Condition:=msoConditionAnytimeBetween, _
Value:="1/1/96", SecondValue:="6/1/96", _
Connector:=msoConnectorAnd
End With
If fs.Execute() > 0 Then
MsgBox "There were " & fs.FoundFiles.Count & _
" file(s) found."
For i = 1 To fs.FoundFiles.Count
MsgBox fs.FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
Use PropertyTests(index), where index is the index number, to return a single PropertyTest object. The following example displays all the search criteria for the first property test in the PropertyTests collection.
With Application.FileSearch.PropertyTests(1)
myString = "This is the search criteria: " _
& " The name is: " & .Name & ". The condition is: " _
& .Condition
If .Value <> "" Then
myString = myString & ". The value is: " & .Value
If .SecondValue <> "" Then
myString = myString _
& ". The second value is: " _
& .SecondValue & ", and the connector is" _
& .Connector
End If
End If
MsgBox myString
End With