View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
kounoike kounoike is offline
external usenet poster
 
Posts: 19
Default Sub cannot run (Error 5)

"Max" wrote in message
...

your code works with no problem for me.
How about opening new workbook, and copy your posted code to the new
workbook, and then try it on the new workbook?

keizi

-------
Sub ListFiles02()
'Using FileSearch to list the files in a directory
Dim i As Integer
i = 1
With Application.FileSearch
.NewSearch
.LookIn = "D:\Program Files\Erlang\CalcA"
.FileName = "*.*"
.SearchSubFolders = True
'.SearchFolders = False
.Execute

For i = 1 To .FoundFiles.Count
Range("B" & i).Value = .FoundFiles(i)
Range("C" & i).Value = FileDateTime(.FoundFiles(i))
Range("D" & i).Value = FileLen(.FoundFiles(i))
Next
End With
End Sub