Sub DisplayTextFile()
Dim fso As New FileSystemObject
Dim t As TextStream
Dim strFilePath As String
Dim strBuffer As String
strFilePath = "C:\test.txt"
If fso.FileExists(strFilePath) Then
Set t = fso.OpenTextFile(strFilePath, ForReading, False)
strBuffer = t.ReadAll
MsgBox strBuffer
t.Close
End If
Set t = Nothing
End Sub
That's not the only problem....you also loose performance (10-15%)Sorry but fake argument, with today's computers running at lightning speed, the peformances decrease isn't even noticeable.
You need to set a reference to the "Microsoft Scripting Runtime" in VBA, which the File System Object is part of.
Jim.