Mcd,
You would be far better off learning about the FileSystemObject and using that in code. I used to struggle with limited skill using "dir >c:\dir_listing.txt" type things, and then struggling to translate the output... but when you have mastered the FSO (and there aint much to mastering it) you will wonder why you ever bothered!
Suck eggs part:
You will need to add the "Microsoft Scripting Runtime" to the References in the VBA window. Select Tools --> References and then scroll down til you find "Microsoft Scripting Runtime" and then tick the box and click OK.
Now use something like this...
================================================== ===========
Public Sub psubListFiles(strFolderPath As String)
Dim fso As FileSystemObject
Dim fldFolder As Folder
Dim sfdFolder As Folder
Dim filFile As File
Set fso = New FileSystemObject
Set fldFolder = fso.GetFolder(strFolderPath)
For Each filFile In fldFolder.Files
Debug.Print fldFolder.Path, filFile.Name
DoEvents
Next filFile
For Each sfdFolder In fldFolder.SubFolders
psubListFiles (sfdFolder.Path)
DoEvents
Next sfdFolder
End Sub
================================================== ===========
You will need to replace the "debug.print..." with whatever you need to use the data, either writing to a table or recordset or whatever.. but should give you a slightly better and more wholesome method for getting this data.
Hope it helps.
|