FileSearch Property

Microsoft Publisher Visual Basic

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 Publisher files in the specified folder. (Note that PathToFolder must be replaced with a valid folder path for this example to work.)

Sub SearchForFiles()

    Dim intCount As Integer

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

End Sub