|
|
Построчное чтение (FSO)
Private Sub ReadTextFileLL()
Dim objFSO As Object, objSRCFile As Object
Dim lLine&, sSRCFilePath$
Const csNewFileExt$ = "csv"
On Error GoTo ReadTextFileLineByLine_Err
sSRCFilePath = "d:\Temp\Excel - Импорт текста\я240417.vbs"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSRCFile = objFSO.OpenTextFile(sSRCFilePath, 1, False)
With objSRCFile
Do While Not .AtEndOfStream
lLine = lLine + 1
Debug.Print .ReadLine
Loop
End With
ReadTextFileLineByLine_End:
On Error Resume Next
objSRCFile.Close: Set objSRCFile = Nothing
Set objFSO = Nothing
Err.Clear
Exit Sub
ReadTextFileLineByLine_Err:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in Sub :" & _
"ReadTextFileLineByLine - Module1.", vbCritical, "Error!"
Err.Clear
Resume ReadTextFileLineByLine_End
End Sub
|
|