View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_3_] Dick Kusleika[_3_] is offline
external usenet poster
 
Posts: 599
Default read last line of a file

Mike

Here's a sub I use to do that

Sub finddstamp()

Dim Fname As String, LastLine As String
Dim Fnum As Integer, i As Integer
Dim CarRet As String

Fname = "C:\Dick\Tester\FindLast.doc"
Fnum = FreeFile

Open Fname For Input As Fnum

For i = LOF(Fnum) To 1 Step -1
Seek #Fnum, i
CarRet = Input(1, #Fnum)
If CarRet = vbCr Or CarRet = vbCrLf Then
Line Input #Fnum, LastLine
MsgBox LastLine
Close Fnum
Exit Sub
End If
Next i

End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Mike" wrote in message
...
Is there a quick way of reading the last line of a plain text file
without having to open it and read each line.

I don't think I can use any of the fancy extensions such as binary mode
or whatever, due to the file being plain text
--
Mike
Please post replies to newsgroup to benefit others
Replace dead spam with ntl world to reply by email