早上好,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