I am using the following script to search for a word and where it finds that word it extracts the text on that particular line into a new text file.
[' Writing Data to a Text File
Const ForReading = 1
Dim words(1)
Dim msg
words(0) = "REV"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set inFile = objFSO.OpenTextFile("C:\Data.txt", ForReading)
Set outFile = objFSO.OpenTextFile("C:\Data-Results.txt", 8, True)
Do Until inFile.AtEndOfStream
strSearchString = inFile.ReadLine
For i = 0 To UBound(words)-1
If InStr(strSearchString,words(i)) Then
msg = msg&strSearchString & vbNewLine
End If
next
Loop
inFile.Close
outfile.WriteLine msg]
I am searching for REV but the problem I have found is that it finds REV in any name example like TREVOR
Is there a way to find the text REV when it stands alone in the text file
Thanks
[' Writing Data to a Text File
Const ForReading = 1
Dim words(1)
Dim msg
words(0) = "REV"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set inFile = objFSO.OpenTextFile("C:\Data.txt", ForReading)
Set outFile = objFSO.OpenTextFile("C:\Data-Results.txt", 8, True)
Do Until inFile.AtEndOfStream
strSearchString = inFile.ReadLine
For i = 0 To UBound(words)-1
If InStr(strSearchString,words(i)) Then
msg = msg&strSearchString & vbNewLine
End If
next
Loop
inFile.Close
outfile.WriteLine msg]
I am searching for REV but the problem I have found is that it finds REV in any name example like TREVOR
Is there a way to find the text REV when it stands alone in the text file
Thanks