Following code works for smaller .txt files (e.g. 10mb). But for large .txt files (e.g., 120mb), it only works once. Then must close and reopen Access to have it work again:
rcdCount returns -1 on second and subsequent tries. BTW, when I execute this code as an Excel VBA macro, it always works.
Any help would be appreciated.
Thanks.
Code:
Function SplitFileIntoLines(PathFileName As String) As String()
FileNum = FreeFile
Open PathFileName For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum, , TotalFile
Close #FileNum
TotalFile = Replace(TotalFile, vbCr, vbLf)
TotalFile = Replace(TotalFile, vbLf & vbLf, vbLf)
SplitFileIntoLines = Split(TotalFile, vbLf)
End Function
FileLines = SplitFileIntoLines(filename)
rcdCount = UBound(FileLines)
Any help would be appreciated.
Thanks.