FileSearch doesn't find zip files

  • Thread starter Thread starter Hub van de Laar
  • Start date Start date
H

Hub van de Laar

L.S.

I created the Macro you find here below. Zip-files that
reside in the directory are not listed. Replacing
Filename "*.zip" by "*.*" lists every file except the zip-
files.
I've reviewed contents in the collections PropertyTests
and Filetypes too, but without results.

Execution of the FileSearch interactively at the Excel-
sheet using the menu-option, has the same result. It also
doesn't list zip-files.

Kind regards,
Hub van de Laar

Private Sub ListZipFiles()
Dim FS As FileSearch, I As Integer
With Application.FileSearch
.NewSearch
.LookIn = "D:\"
.FileType = msoFileTypeAllFiles
.Filename = "*.zip"
.SearchSubFolders = False
If .Execute > 0 Then
For I = 1 To .FoundFiles.Count
Debug.Print .FoundFiles(I)
Next I
Else
MsgBox "There were no files found."
End If
End With
End Sub
 
Try the Dir function

Sub test()
Dim wb As Workbook
Dim TheFile As String
Dim MyPath As String
MyPath = "C:\"
ChDir MyPath
TheFile = Dir("*.zip")
Do While TheFile <> ""
Debug.Print TheFile
TheFile = Dir
Loop
End Sub
 
Ron,

Sorry, I posted too many times the same item, but the
message was confusing: "Your message should be posted
within a few minutes". So I was trying faster and faster.
Can someone replace the "should" by "will" ?

Ofcourse, the Dir function can be used. But the Dir
function is complicated to be used for scanning
subdirectories too. Recursive prograaming is not possible
since Dir looses track wehen reentering a higher level. I
once circumvented this problem with an quite extensive
macro. FileSearch should work simpler?

Kind regards,
Hub
-----Original Message-----
Try the Dir function

Sub test()
Dim wb As Workbook
Dim TheFile As String
Dim MyPath As String
MyPath = "C:\"
ChDir MyPath
TheFile = Dir("*.zip")
Do While TheFile <> ""
Debug.Print TheFile
TheFile = Dir
Loop
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)




"Hub van de Laar" <[email protected]> wrote in
message news:[email protected]...
 
Try changing

.Filename = "*.zip"

to


.Filename = ".zip"

Either one works for me (xl97, win 98 SE) but
my understanding is that the latter is the more robust of the two.
 
Back
Top