View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
chad chad is offline
external usenet poster
 
Posts: 273
Default Display Contents of Folder

Is it possible to get a list of the entire folder contents, including other
folders that may exist? This code works perfectly to list all files outside
of folders within the desired destination.

Thanks!


"Zone" wrote:

This will put a list of files in column G. Change MYPATH to the path for
the folder you want to look at, ending with a backslash \ Hope this
helps, James

Const MYPATH = "c:\MyFiles\"

Sub ListFiles()
Dim PutRow As Long, fName As String
PutRow = 1
Columns("g").Clear
fName = Dir(MYPATH & "*.*")
Cells(PutRow, "g") = fName
PutRow = PutRow + 1
Do
fName = Dir
Cells(PutRow, "g") = fName
PutRow = PutRow + 1
Loop Until fName = ""
End Sub

"Chad" wrote in message
...
I'm in need of VBA code that will list in an Excel sheet the filenames of
all
documents of a specific folder. Any help on this is much appreciated.

Thanks,
Chad