Here is a code snippet where I shell to DOS to execute a DIR command to create a text file. I then read the text file into a database table, line by line.
I did need to add some delay timers into the process, since the DIR to create a text file was not finishing before the next lines of code were finishing... htwh
Set oFSO = CreateObject("Scripting.FileSystemObject"
'create a directory listing by writing a batch file and executing it
sCommand = "dir " & rsBase("basepath"

& "*.mdb /s /b /o-s >" & APP_PATH & "dir_list_mdb.lst"
Open APP_PATH & "dir.bat" For Output As #1
Print #1, sCommand
Close #1
'appLoop Shell(APP_PATH & "dir.bat"

wHandle = Shell(APP_PATH & "dir.bat"
'delay to wait for the directory list
'file to finish writing from the bat command. This is necessary becuase
'the Shell command is asyncronous
DelayTime 5
appLoop wHandle
'clear the working table
thisdb.Execute "delete from dir_list"
'load the directory listing into the working table DIR_LIST
While Not rsBase.EOF
'open the directory list file and load it into a table
Open APP_PATH & "dir_list_mdb.lst" For Input As #1
Set rsDirList = thisdb.OpenRecordset("select * from dir_list order by 1, 2"

Do While Not EOF(1)
Input #1, sFilePath
'strip the base path to save the overall number of characters
If InStr(1, sFilePath, rsBase("basepath"

) <> 0 Then
sFilePath = Mid(sFilePath, Len(rsBase("basepath"

) + 1)
End If
'add it to the table
With rsDirList
.AddNew
.Fields("basepath"

= rsBase("basepath"

.Fields("filepath"

= sFilePath
.Update
End With
Loop 'end doloop not EOF(1)
Close #1
.....
Public Function DelayTime(PauseTime As Integer)
Dim start
'PauseTime = 4 ' Set duration.
start = Timer ' Set start time.
Do While Timer < start + PauseTime
DoEvents ' Yield to other processes.
Loop
End Function
Sub appLoop(wHandle As Long)
On Error GoTo errorhandler
Do While 1
AppActivate wHandle, False
Loop
errorhandler:
Exit Sub
End Sub
Steve Medvid
"IT Consultant & Web Master"