I\'m trying to read a text file using vba. I tried the below code
Open \"C:\\tester.txt\" For Input As #1
Worksheets(\"UI\").Range(\"H12\").Value = Input$(LO
Fidel's answer, over Brettdj's answer, adjusted for ASCII or Unicode and without magical numbers:
Public Function readFileContents(ByVal fullFilename As String, ByVal asASCII As Boolean) As String
Dim objFSO As Object
Dim objTF As Object
Dim strIn As String
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTF = objFSO.OpenTextFile(fullFilename, IOMode:=ForReading, format:=IIf(asASCII, TristateFalse, TristateTrue))
strIn = objTF.ReadAll
objTF.Close
readFileContents = strIn
End Function