ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FileSearch doesn't find zip files (https://www.excelbanter.com/excel-programming/275814-filesearch-doesnt-find-zip-files.html)

Hub van de Laar

FileSearch doesn't find zip files
 
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


Ron de Bruin

FileSearch doesn't find zip files
 
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)
www.rondebruin.nl



"Hub van de Laar" wrote in message ...
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




Hub van de Laar

FileSearch doesn't find zip files
 
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)
www.rondebruin.nl



"Hub van de Laar" wrote in

message ...
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



.


Tom Ogilvy

FileSearch doesn't find zip files
 
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.

--
Regards,
Tom Ogilvy

Hub van de Laar wrote in message
...
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





All times are GMT +1. The time now is 02:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com