Hello Quinto,
One way to do this is by the function below, but take in mind that your
original file
wil be overwritten and you could expand the function with some code that
copies
your original file. TRY THIS function first with a dummy file !!!
When I runned the function multiple times on the same file, this file was
damaged at the end for unknown reasons. Let me know if you have the same
problems.
grtz
***********************************************************
Function deleteLinesInTextFileForQuinto(file As String, criterium As String)
Dim fs, f, fTemp As Object
Dim ln As String
Dim tempFile As String
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
On Error GoTo Error_deleteLinesInTextFileForQuinto
tempFile = Replace(file, ".txt", "_temp.txt")
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(file, ForReading) 'your text file
Set fTemp = fs.CreateTextFile(tempFile, ForWriting, True) 'temporary text file
Do Until f.AtEndOfStream
ln = f.ReadLine
If ln Like "*" & criterium & "*" Then
'skip
Else
fTemp.WriteLine ln
End If
Loop
f.Close
fTemp.Close
fs.CopyFile tempFile, file, True
fs.DeleteFile tempFile
Exit Function
Error_deleteLinesInTextFileForQuinto:
MsgBox ("Error " & Err & "(" & Err.Description & ") has occurred in
procedure <deleteLinesInTextFileForQuinto> !"), vbCritical
End Function
**********************************************************