早上好,VBA_using“线路输入”,但失败(错误62:输入过去文件的结尾)
我试图以写代码: 1.打开一个txt。文件,其中包含文件 2.打开列表中的一个接一个 3.read每个文件中的内容的文件的列表,并把它放在表
我的代码是在这里:
Private Sub Boutton_Importer_Click()
list_de_controle = "TEXT;" & listPath
Open listPath For Input As #1 'open the list
Do While Not EOF(1) 'read the list
Line Input #1, nom_de_Fich
ActiveCell = nom_de_Fich
ActiveCell.Offset(0, 1).Select
Open nom_de_Fich For Input As #2 'open a file in the list
Do While Not EOF(1) 'read the contents in the list
Line Input #2, contenu
ActiveCell = contenu
ActiveCell.Offset(0, 1).Select
Loop
Close #2
ActiveCell.Offset(1, 0).Select 'go to the line below
ActiveCell.End(xlToLeft).Select
Loop
Close #1
End Sub
您可能会发现Do While的两部分完全相同,但列表中的第一部分运行良好。 而第二个,对于文件中的内容,总是失败。 你能帮我检查一下吗? 提前谢谢!
我忘记了一些东西,在列表中的第一个文件可以打开,所有的内容可以以表来读取,但接下来的文件可以不会被打开。所以我认为问题在于EOF无法确定它是否已经达到最终结果。 – Hiddenllyy