Importing text files saved from word forms

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
 
D

Douglas J. Steele

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
 
L

Laurie

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top