Sub ConvertirCSVenSeq()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim Fso As Object, Csv As Object, Txt As Object, Champ As Variant
' Alignement et longueur de chaque colonne en sortie -------------------------
Dim Alg: Alg = Array("Left", "Left", "Left", "Right", "Left", "Left", "Left")
Dim Lng: Lng = Array(35, 12, 4, 9, 9, 4, 35)
Chemin = ThisWorkbook.Path & "\"
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Csv = Fso.OpenTextFile(Chemin & "FichierDépart.txt", ForReading)
Set Txt = Fso.OpenTextFile(Chemin & "FichierArrivée2.txt", ForWriting, True)
Do Until Csv.AtEndOfStream
Champ = Split(Csv.Readline, ";")
For i = 0 To Ubound(Champ)
Champ(i) = Replace(Champ(i), """", "")
If Alg(i) = "Left" Then
Champ(i) = Left(Champ(i) & Space(Lng(i)), Lng(i))
Else
Champ(i) = Right(Space(Lng(i)) & Champ(i), Lng(i))
End If
Next
Txt.writeline Join(Champ, "|")
Loop
Csv.Close
Txt.Close
Set Fso = Nothing
End Sub