Importing text files saved from word forms

  • Thread starter Thread starter Laurie
  • Start date Start date
L

Laurie

Hello,

I have created a user form in Word that I will save as a text file, then
import into Excel 1 by 1, then copy and paste into an Access table. Importing
the text files 1 by 1 into Access doesn't work because I need both a "tab"
and a comma as delimiters, and Access only allows one.

Is there a quicker way to do this? I will be working with probably 1,400
files. Any way to import many text files into either Excel or Access?

Thanks much!

Laurie
 
You can read the file in line by line using the Line Input # statement, use
the Split function (once for each delimiter) to break the row into the
individual fields, then create an INSERT INTO query and execute it.

To handle multiple files, you can use the Dir function:

Dim strFolder As String
Dim strFile As String

strFolder = "C:\Folder\"
strFile = Dir(strFolder & "*.txt")
Do While Len(strFile) > 0
' At this point, strFolder & strFile will point to a specific file to be
imported.
' Import that file...
strFile = Dir()
Loop
 
Thanks, I'll work on that.



Douglas J. Steele said:
You can read the file in line by line using the Line Input # statement, use
the Split function (once for each delimiter) to break the row into the
individual fields, then create an INSERT INTO query and execute it.

To handle multiple files, you can use the Dir function:

Dim strFolder As String
Dim strFile As String

strFolder = "C:\Folder\"
strFile = Dir(strFolder & "*.txt")
Do While Len(strFile) > 0
' At this point, strFolder & strFile will point to a specific file to be
imported.
' Import that file...
strFile = Dir()
Loop
 
Back
Top