Looping through files in a folder (1 Viewer)

pdbowling

Registered User.
Local time
Today, 10:22
Joined
Feb 14, 2003
Messages
179
Good day, all.

I would like to loop through the files in a folder and do some basic processing. I've done it before but seem to have misplaced the code.
Any suggestions?

Using Access 2003 SP1.

Thanks
PB
 

simongallop

Registered User.
Local time
Today, 10:22
Joined
Oct 17, 2000
Messages
611
The following code will look through all subfolders, returning mdb files to a table. Amend, play etc!

Set rstMDB = CurrentDb.OpenRecordset("Found", dbOpenDynaset)
With Application.FileSearch
.NewSearch
.LookIn = "k:\"
.SearchSubFolders = True
.FileName = ""
.MatchAllWordForms = True
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
If Right(.FoundFiles(i), 3) = "mdb" Then
FileNo = FileNo + 1
rstMDB.AddNew
rstMDB("FileName") = .FoundFiles(i)
rstMDB.Update
End If
Next i
MsgBox "TOTAL FILES: " & FileNo
Else
MsgBox "There were no files found."
End If
End With
 

modest

Registered User.
Local time
Today, 05:22
Joined
Jan 4, 2005
Messages
1,220
The answer to this exists in another thread.
 

Users who are viewing this thread

Top Bottom