Hi im using the below macro to delete first 2 lines of txt files in a folder
Private Sub remove()
Dim FSO, txs, fld, fil As file, content, nLinesToSkip, i
Set FSO = CreateObject("Scripting.FileSystemObject")
nLinesToSkip = 2
fld = FSO.GetFolder("O:\New folder\")
For Each fil In fld
If Right(fil.Name, 3) = "txt" Then
Set txs = fil.OpenAsTextStream(1) ' 1 = for reading
For i = 1 To nLinesToSkip
txs.SkipLine
Next i
content = txs.ReadAll
txs.Close
Set txs = fil.OpenAsTextStream(2) ' 2 = for writing
txs.Write content
txs.Close
End If
Next fil
End Sub
while running this script im getting type mismatch error for line For Each fil In fld
would appreciate if anyone can assist in solving this issue