VBA/Excel/Access/Word/File Path/File Read Write
Create a new file
Sub MakeFile()
Open "c:\longfile.txt" For Output As #1
For c = 1 To 300
Write #1, "Field" & Format(c, "000");
Next c
Print #1,
For r = 1 To 100
For c = 1 To 300
If c <> 300 Then
Write #1, Int(Rnd * 1000);
Else
Write #1, Int(Rnd * 1000)
End If
Next c
Next r
Close
End Sub
Filter File
Sub FilterFile()
On Error Resume Next
Open "c:\infile.txt" For Input As #1
Open "c:\output.txt" For Output As #2
If Err <> 0 Then
MsgBox "Error reading or writing a file."
Exit Sub
End If
TextToFind = "January"
Do While Not EOF(1)
Line Input #1, data
If InStr(1, data, TextToFind) Then
Print #2, data
End If
Loop
Close
End Sub