I have a text file that each line starts with:
TC
PR
EO
FC
CK
I need to write to a new text file only the lines that start with EO, TC, or CK - AND - the very next line for each EO, TC, or CK
Below is what I'm working with...
Any suggestions or examples would be much appreciated..!!
Thanks in advance..!!
jcw5107
Sub NewUnAssignedTasks()
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim strLine 'As Variant
Dim strType As Variant
Dim MyString As String
Dim strImportFile As String
Dim strNewfile As String
Set db = CurrentDb
strImportFile = "D:\UPSDATA\NewTaskNos.txt"
strNewfile = "D:\UPSDATA\NewTaskNos.txt"
Open "D:\UPSDATA\NewUnAssignedTaskNos.txt" For Input As #1
Open strImportFile For Output As #2
Do Until EOF(1)
Line Input #1, strLine
If Left(strLine, 2) = "EO" _
Or Left(strLine, 2) = "TC" _
Or Left(strLine, 2) = "CK" Then
strType = strLine
Print #2, strType
End If
Loop
Close #1
Close #2
End Sub
TC
PR
EO
FC
CK
I need to write to a new text file only the lines that start with EO, TC, or CK - AND - the very next line for each EO, TC, or CK
Below is what I'm working with...
Any suggestions or examples would be much appreciated..!!
Thanks in advance..!!
jcw5107
Sub NewUnAssignedTasks()
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim strLine 'As Variant
Dim strType As Variant
Dim MyString As String
Dim strImportFile As String
Dim strNewfile As String
Set db = CurrentDb
strImportFile = "D:\UPSDATA\NewTaskNos.txt"
strNewfile = "D:\UPSDATA\NewTaskNos.txt"
Open "D:\UPSDATA\NewUnAssignedTaskNos.txt" For Input As #1
Open strImportFile For Output As #2
Do Until EOF(1)
Line Input #1, strLine
If Left(strLine, 2) = "EO" _
Or Left(strLine, 2) = "TC" _
Or Left(strLine, 2) = "CK" Then
strType = strLine
Print #2, strType
End If
Loop
Close #1
Close #2
End Sub