1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| Sub test()
Dim intFic As Long
Dim Txt As String
Dim Le
intFic = FreeFile
Open "C:\RepTest\test.txt" For Input As intFic 'ouvrir le fichier
While EOF(intFic) = False
Line Input #intFic, Txt 'lire une ligne
EcrireExcel Sheets("Import"), Txt 'traiter la ligne
Wend
Close intFic
End Sub
Sub EcrireExcel(Feuille As Worksheet, Txt As String)
Dim Pose
Dim derL As Long
Dim c As Integer
derL = Feuille.Range("A" & Feuille.Cells.Rows.Count).End(xlUp).Row + 1
c = 1
'pose(Start,Length,Start,Length)
'Mid(Txt,Start, Length)
'star1,Length1,Star2=star1+Length1,Length2
Pose = Array(1, 6, 7, 8, 15, 4,19, 5)
For I = 0 To UBound(Pose) Step 2
Feuille.Cells(derL, c) = Mid(Txt, CLng(Pose(I)), CLng(Pose(I + 1))) 'découpe la ligne
c = c + 1
Next
End Sub |
Partager