'' Read the entire file into a string variable via a binary get
'' and then use the split function to parse it into a string array.
'' There may be other ways to skin this cat in VBA but I challenge
'' them (invitation extended) to perform faster.
''
'' Minimalist code, observe --
Sub Test()
Dim streams() As String
'' please use a valid path in the following
streams = FileToArray("c:\docs\text.txt")
Debug.Print (UBound(streams) - LBound(streams)) + 1; "line(s) of text retrieved."
End Sub
Function FileToArray(filename As String) As String()
On Error GoTo errhandler
Dim handle As Integer, _
stream As String
handle = FreeFile
Open filename For Binary As #handle
stream = Space(LOF(handle))
Get #handle, , stream
Close handle
FileToArray = Split(stream, vbCrLf)
Exit Function
errhandler:
Close handle
Resume exitnow
exitnow:
End Function