I found away around by changing the dim type to LONG.
I use the following VBA:
Public Function textStreamRead(fileLocation As String) as Integer
Dim tso As TextStream
Dim strLine As String
Dim lineCount As Integer
lineCount = 0
textStreamRead = 0
Set fso = CreateObject("Scripting.FileSystemObject")
Set tso = fso.OpenTextFile(fileLocation, ForReading)
Do While Not tso.AtEndOfStream
strLine = tso.ReadLine()
lineCount = lineCount + 1
Loop
textStreamRead = lineCount - 1 'Header
tso.Close
End Function
When file limit exceeded 32767 I received the Overflow error.
I changed the function data type and line count variable to long.
This is my revision, works like a charm.
Public Function textStreamRead(fileLocation As String) As Long
Dim tso As TextStream
Dim strLine As String
Dim lineCount As Long
lineCount = 0
textStreamRead = 0
Set fso = CreateObject("Scripting.FileSystemObject")
Set tso = fso.OpenTextFile(fileLocation, ForReading)
Do While Not tso.AtEndOfStream
strLine = tso.ReadLine()
lineCount = lineCount + 1
Loop
textStreamRead = lineCount - 1 'Header
tso.Close
End Function