checking text files before importing

Mcgrco

Registered User.
Local time
Today, 16:48
Joined
Jun 19, 2001
Messages
118
i want Access to open a text file and remove certain characters before importing. Im struggling. Can anyone help me with my code please. I want to replace all instances of " with \. So far i have :

Dim mfile As String
Dim mfileO As String

mfile = "C:\WINNT\Profiles\mcgrco\Desktop\MYFILE.txt"
mfileO = "C:\WINNT\Profiles\mcgrco\Desktop\MYFILE1.txt"

Dim InputData
Open mfile For Input As #1


Do While Not EOF(1) ' Check for end of file.
Line Input #1, InputData


Any help would be greatfully appreciated
 
Try this.

Public Function ConvertText()
Dim ReadRecord As String, WriteRecord As String, Pos As Integer
Open "C:\TESTFILE.TXT" For Input As #1
Open "C:\OutTESTFILE.TXT" For Output As #2
While Not EOF(1)
Line Input #1, ReadRecord ' Read line of data.
WriteRecord = ReadRecord
Pos = 0
While Pos < Len(WriteRecord) 'Parse the record to change the characters.
Pos = Pos + 1
If Mid(WriteRecord, Pos, 1) = Chr$(34) Then
Mid(WriteRecord, Pos, 1) = "\"
End If
Wend
Print #2, WriteRecord ' Write the record
Wend
Close #1
Close #2
End Function
 
Cheers. very much appreciated
 

Users who are viewing this thread

Back
Top Bottom