I have a text file where I need to add the line number on each line. I have some code that "cleans the text file up" before it is imported into a table. Is there a way to print the line number for each line (on the left or begining of each line) when the text data is written to a new file..??
I'm just havin' troubles doin' this + finding a post that has an example to work from... The text file will have about 150 to 200 lines on it.
Below is the code that cleans the file up and prints it to a new .txt file..
Any suggestions or examples...???
Thanks in advance..!!
jcw5107
Sub MakePRFSWfile()
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim strLine 'As Variant
Dim strType As Variant
Dim strImportFile As String
Dim strNewfile As String
Set db = CurrentDb
strImportFile = "D:\UPSDATA\PRFSW.txt"
strNewfile = "D:\UPSDATA\PRFSW1.txt"
Open "D:\UPSDATA\PRFSW1.txt" For Input As #1
Open strImportFile For Output As #2
Do Until EOF(1)
Line Input #1, strLine
If Left(strLine, 3) Like "N#*" Then
strType = strLine
Print #2, strType
End If
Loop
Close #1
Close #2
DoCmd.TransferText acImportFixed, "PRFSW Spec", _
"PRFSWVarying", strImportFile, False
Kill strNewfile
End Sub
I'm just havin' troubles doin' this + finding a post that has an example to work from... The text file will have about 150 to 200 lines on it.
Below is the code that cleans the file up and prints it to a new .txt file..
Any suggestions or examples...???
Thanks in advance..!!
jcw5107
Sub MakePRFSWfile()
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim strLine 'As Variant
Dim strType As Variant
Dim strImportFile As String
Dim strNewfile As String
Set db = CurrentDb
strImportFile = "D:\UPSDATA\PRFSW.txt"
strNewfile = "D:\UPSDATA\PRFSW1.txt"
Open "D:\UPSDATA\PRFSW1.txt" For Input As #1
Open strImportFile For Output As #2
Do Until EOF(1)
Line Input #1, strLine
If Left(strLine, 3) Like "N#*" Then
strType = strLine
Print #2, strType
End If
Loop
Close #1
Close #2
DoCmd.TransferText acImportFixed, "PRFSW Spec", _
"PRFSWVarying", strImportFile, False
Kill strNewfile
End Sub