I've got the following code which allows me to delete lines from a text file based on a input value i.e. a date 001:2003 etc etc The code works fine for one file at a time , but how could I modify it so as it looks at all files in a directory and modifies them accordingly?
Dim inz As String
Dim outz As String
Dim remove As String
Dim remove2 As String
inz = Me.txtXLFIle
outz = Me.txtXLFIle
remove = Me.Text7
'remove2 = Me.Text9
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(inz, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If InStr(strLine, remove) = 0 Then
strNewContents = strNewContents & strLine & vbCrLf
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile(outz, ForWriting)
objFile.Write strNewContents
objFile.Close
End Sub
Bookmarks