Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import all text files in a directory

Status
Not open for further replies.
Jul 15, 2002
9
AU
What I need is a function that will read all of the files in a directory (about 20 or so), and then import the lot of them one at a time using the same set of rules. I have got this worked out for one file(you have to specify the path, and filename), but I wanted to get it to automatically import all files in a given directory(specify only the directory). This will save me from having to run the import 20 times.

Thanks in advance

James
 
I found this in AccessXP help - dir :

Set fs = Application.FileSearch

With fs
.LookIn = "C:\My Documents"
.FileName = "cmd*"
If .Execute(SortBy:=msoSortbyFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
Maby this can help you. I am not trying to put down by saying that I found it help ;-) - help can differcoult to use and it can be hard to find the A's to the Q's that you have.
Rgds
 
Thanks Herman!

That was exactly what I was looking for. I did have a look in the help, but it is hard to guess the keywords to search for...

Thanks
James Moffitt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top