H
Howard Jacobs
I am having trouble with FileSearch:
With Application.FileSearch
For i = 1 To .SearchFolders.Count
.SearchFolders.Remove i
Next i
.NewSearch
.LookIn = "C:\My Documents"
.SearchSubFolders = True
.FileName = "*.*"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles ' *******************
MsgBox "You are about to search for " & .FileTypes.Count & _
" file types."
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
The above code does not compile even though it is copied from "Help" -
msoFileTypeAllFiles is "Variable undefined".
If I omit that line the search returns 0 files.
Pls advise
HJ
With Application.FileSearch
For i = 1 To .SearchFolders.Count
.SearchFolders.Remove i
Next i
.NewSearch
.LookIn = "C:\My Documents"
.SearchSubFolders = True
.FileName = "*.*"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles ' *******************
MsgBox "You are about to search for " & .FileTypes.Count & _
" file types."
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
The above code does not compile even though it is copied from "Help" -
msoFileTypeAllFiles is "Variable undefined".
If I omit that line the search returns 0 files.
Pls advise
HJ