How can I print the list of files in a folder to another file?

H

HalF

There are times when I would like to make a list of the folders in a
directory or the files in a folder. I recall being able to do this in DOS
with a comman like Dir a: (etc).
 
D

Douglas J. Steele

Dim strFolder As String
Dim strFile As String

strFolder = "C:\Data Files\"
strFile = Dir(strFolder & "*.*")
Do While Len(strFile) > 0
Debug.Print strFolder & strFile
strFile = Dir()
Loop
 
A

Allen Browne

This group is about Microsoft Access the database.

You can get a directory lisiting into a file:
dir a:\ /s /a >files.txt
Then use notepad to open the text file and print it.
 
Top