By using expertatexcel.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

expertatexcel.com

 


LoadFileToString(sFile) - udf


Function LoadFiletoString(sFile As String)

If dir(sFile) = "" then
    Msgbox  sFile & " doesn't exist, can't load data"
    End
End If

x = bOpenSeqFile(sFile,"I")
if x < 0 then
    Msgbox "Error " & x & " opening file " & sFile & " " & Error(abs(x))
    End
End if

Line Input #x,s
strrec = s & vbCRLF
Do while not eof(x)
    Line input #x, s
    strRec = strRec & s & vbCRLF

Loop
Close #x
LoadFiletoString = strrec
End Function