Home > other >  The path/file access error how to adjust? The Open FileName (t) For Input As # I runtime error 75
The path/file access error how to adjust? The Open FileName (t) For Input As # I runtime error 75

Time:10-23

Rookie in using vba will batch TXT import excel vba always found in the Open FileName (t) For Input As there was an error # I run 75, adjust a few times file location and file name format is useless, the great god of all stripes have better solution?

In the excel module running in the VBA code is as follows:
Option Explicit
Public Const sPath As String="F: \ Output860" 'read TXT path
Dim FileName () As String 'to deal with the file name
Dim MyString () As String 'reading from the text content
Sub ReadFile ()
Dim getLine 'each read a row
Dim I %, t % k %
I=FreeFile
Open "F: \ list. TXT" For Input As # I Open TXT file names containing needed to read file,
The Do While Not EOF (I)
Input the # I, getLine 'data into variables,
T=t + 1
Loop
K=t - 1
MyString ReDim FileName (k), (k)
T=0
Seek the # I, 1 'Settings file first record
The Do While Not EOF (I)
Input the # I, FileName (t)
FileName (t)=sPath & amp; "" & amp; FileName (t)
T=t + 1
Loop
Close # I "Close the file,

'read TXT content to the excel spreadsheet
For t=0 To k
I=FreeFile
The Open FileName (t) For Input file error As # I 'always
The Do While Not EOF (I)
Input the # I, getLine
MyString=MyString (t) (t) & amp; VbNewLine & amp; GetLine
Loop
Close # I
With ThisWorkbook. Sheets (1)
Cells (t + 1, 1)=FileName (t)
Cells (t + 1, 2)=Right (MyString (t), Len (MyString (t)) - 2)
End With
Next t

End Sub

CodePudding user response:

Error code 75 is the file is not found,
File path and file format,
  • Related