KillGorack
New Member
- Joined
- Jan 23, 2006
- Messages
- 35
- Office Version
- 2016
- Platform
- Windows
Reading a text file, while it works most of the time Ive ran into a situation where it does not.
When running the code below I get a Input past the end of file error at the "strFileText = Input(LOF(iFile), iFile)" line
The files it opens exist, and are text files, is there anything I should be looking for?
When running the code below I get a Input past the end of file error at the "strFileText = Input(LOF(iFile), iFile)" line
The files it opens exist, and are text files, is there anything I should be looking for?
VBA Code:
Sub ASubRoutineOfSorts()
h = ActiveWorkbook.Sheets("files").Cells(Rows.Count, 1).End(xlUp).Row
Set DMOData = CreateObject("Scripting.Dictionary")
Dim strFileName As String
Dim strFileText As String
Dim iFile As Integer: iFile = FreeFile
For x = 2 To h
strFileName = ThisWorkbook.Sheets("files").Cells(x, 1).Value
If CheckFileExists(CStr(strFileName)) = True Then
Open strFileName For Input As #iFile
strFileText = Input(LOF(iFile), iFile)
Close #iFile
' do stuff..
End If
Next x
End Sub