Read String of Text or HTML from a File


Public Function FileRead2String(strFile As String) As String
On Error Resume Next
'?FileRead2String("c:\test.txt")
Dim mhFile As Long
Dim strLine As String, strOut As String, strDir As String
    mhFile = FreeFile
    Open strFile For Binary Access Read As mhFile
    If LOF(mhFile) > 0 Then
        Do Until EOF(mhFile)
            Line Input #mhFile, strLine
            strOut = strOut & vbCrLf & strLine
        Loop
    End If
    If Len(strOut) > Len(vbCrLf) Then
        strOut = Mid(strOut, Len(vbCrLf) + 1)
    End If
    FileRead2String = strOut
    Close #mhFile
End Function