ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Directory List (https://www.excelbanter.com/excel-programming/305491-directory-list.html)

Dominique Feteau

Directory List
 
Is there a macro out there that will list all the names of files in a folder
I specify?

Thanks



Ron de Bruin

Directory List
 
Hi Dominique

One way

Run this with a empty sheet active

Sub test2()
Dim i As Long
With Application.FileSearch
.NewSearch
.LookIn = "c:\Data"
.SearchSubFolders = False
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) 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


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Dominique Feteau" wrote in message ...
Is there a macro out there that will list all the names of files in a folder
I specify?

Thanks





Jim Cone

Directory List
 
Dominique,

Or my "List Files" Excel add-in will do that.
It finds files with the extension you specify, such as *.xls, in the folder
you specify and returns a list on a new worksheet.
Each file is hyperlinked and gives the file name, path, size and date last modified.
It can be sorted.
Comes with a one page install/use Word.doc.
Available free upon direct request. Remove xxx from my email address.

Regards,
Jim Cone
San Francisco, CA
XX


"Dominique Feteau" wrote in message ...
Is there a macro out there that will list all the names of files in a folder
I specify?
Thanks




All times are GMT +1. The time now is 12:13 AM.

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