SearchSubFolders 属性

       

如果搜索范围包括 LookIn 属性指定的文件夹中的所有子文件夹,则返回 TrueBoolean 类型,可读写。

示例

本示例可实现的功能为:在“My Documents”文件夹及其所有子文件夹中查找文件名以“Cmd”开头的文件,并显示查找到的每个文件的文件名及其所在位置。

Set fs = Application.FileSearch
With fs
    .LookIn = "C:\My Documents"
    .SearchSubFolders = True
    .FileName = "cmd*"
    If .Execute() > 0 Then
        MsgBox "There were " & .FoundFiles.Count & _
         " file(s) found."
        For i = 1 To .FoundFiles.Count
            MsgBox .FoundFiles(i)
        Next i
    Else
        MsgBox "There were no files found."
    End If
End With