I have a batch of like 100,000 text files which I would like to extract as strings using vba. In the past I have been doing so this way without problem:
Sub Main()
Dim PathAndName As String
Dim TextFile As Integer
Dim TextString() As String
Redim TextString(100000)
For i = 1 To 100,000
PathAndName = "C:\File_" & i & ".ext"
TextFile = 1
Open PathAndName For Input As TextFile
TextString(i) = Input(LOF(TextFile), TextFile)
Next i
End Sub
This time, the script returns the error "Input Past End of File" Error 62. The only different I can spot is that this time the text files contain a few Chinese Characters, which are not of my interest actually. That's why I believe this is the source of the problem. The Chinese Characters appear at the first line of the files.
Any help is appreciated. Thanks!
PathAndName = "C:\File_" & i & ".ext"should bePathAndName = "C:\File_" & i & ".txt". and addClose TextFilebeforeNext i