I had to think out of the box on this one.
Conor, this should work for you. It's the only way I could think of doing it since there isn't a method to delete a line from a text file.
It actually reads all lines except the first 5 and writes them to a new file then delete the old file and rename the new file. Hope it helps.
Sub DeleteLines()
Dim sData As String
Dim sOrgFile As String
Dim sDestFile As String
Dim iCounter As Integer
'Assign File Names
sOrgFile = Application.GetOpenFilename
sDestFile = "C:\Tmp_Holding_File.txt"
iCounter = 0
'Open Files
Open sOrgFile For Input As #1
Open sDestFile For Output As #2
'Start
Do While Not EOF(1)
iCounter = iCounter + 1
Line Input #1, sData
If iCounter > 5 Then
Print #2, sData
End If
sData = ""
Loop
Close #1
Close #2
Kill sOrgFile
FileCopy sDestFile, sOrgFile
Kill sDestFile
End Sub
Jerid
'Assign File Names sOrgFile = Application.GetOpenFilename sDestFile = "C:\Tmp_Holding_File.txt" iCounter = 0 Open sOrgFile For Input As #1 Open sDestFile For Output As #2 'Start Do While Not EOF(1) iCounter = iCounter + 1 Line Input #1, sData If iCounter > 5 Then Print #2, sData End If sData = "" Loop Close #1 Close #2 FileCopy sDestFile, sOrgFile Kill sDestFile