LookIn 属性
优质
小牛编辑
131浏览
2023-12-01
返回或设置在指定的文件搜索过程中要搜索的文件夹。String 类型,可读写。
示例
本示例可实现的功能为:在“My Documents”文件夹中查找文件名以“Cmd”开头的文件,并显示找到的每个文件的文件名及其所在位置。
Set fs = Application.FileSearch
With fs
.LookIn = "C:\My Documents"
.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