FileSearch Property

       

Returns a FileSearch object that can be used to search for files using either an absolute or relative path.

expression.FileSearch

expression   Required. An expression that returns one of the objects in the Applies To list.

Example

This example displays, in a series of message boxes, the file names of all Microsoft Publisher files in the Documents folder.

Sub SearchForFiles()

    Dim intCount As Integer

    With Application.FileSearch
        .FileName = "*.pub"
        .LookIn = "C:\Documents"
        .Execute
        For intCount = 1 To .FoundFiles.Count
            MsgBox .FoundFiles(intCount)
        Next intCount
    End With

End Sub