![]() |
Filesearch : .zip files not found ???
Hi all,
I've got a problem with this piece of code, which lists the contents of a directory (thanks Ron de Bruin). It works fine with all but zip files. Files with .zip extension are not found, not counted ... why the hell ??? (Excel 2003, XP Pro) thanks for your help ! Sub test2() Dim i As Long With Application.FileSearch .NewSearch .LookIn = "c:\Data" .SearchSubFolders = False .MatchTextExactly = False .FileType = msoFileTypeAllFiles If .Execute 0 Then MsgBox "There were " & .FoundFiles.Count & " file(s) found." For i = 1 To .FoundFiles.Count Cells(i, 1).Value = .FoundFiles(i) Cells(i, 2).Value = FileDateTime(.FoundFiles(i)) Cells(i, 3).Value = FileLen(.FoundFiles(i)) Next i Else MsgBox "There were no files found." End If End With End Sub |
Filesearch : .zip files not found ???
Hi
There are some problems with Application.FileSearch in Excel 2002/2003 with WinXP You can use the Dir function (always working) Sub TestFile() Dim rnum As Long Dim FNames As String Dim MyPath As String Dim SaveDriveDir As String SaveDriveDir = CurDir MyPath = "C:\Data" ChDrive MyPath ChDir MyPath FNames = Dir("*.*") If Len(FNames) = 0 Then MsgBox "No files in the Directory" ChDrive SaveDriveDir ChDir SaveDriveDir Exit Sub End If Application.ScreenUpdating = False rnum = 1 Do While FNames < "" ActiveSheet.Cells(rnum, "A").Value = FNames rnum = rnum + 1 FNames = Dir() Loop ChDrive SaveDriveDir ChDir SaveDriveDir Application.ScreenUpdating = True End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Benoît HUBERT" wrote in message ... Hi all, I've got a problem with this piece of code, which lists the contents of a directory (thanks Ron de Bruin). It works fine with all but zip files. Files with .zip extension are not found, not counted ... why the hell ??? (Excel 2003, XP Pro) thanks for your help ! Sub test2() Dim i As Long With Application.FileSearch .NewSearch .LookIn = "c:\Data" .SearchSubFolders = False .MatchTextExactly = False .FileType = msoFileTypeAllFiles If .Execute 0 Then MsgBox "There were " & .FoundFiles.Count & " file(s) found." For i = 1 To .FoundFiles.Count Cells(i, 1).Value = .FoundFiles(i) Cells(i, 2).Value = FileDateTime(.FoundFiles(i)) Cells(i, 3).Value = FileLen(.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 08:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com