Sub Exportxt()
Dim File As Variant
Dim Fso As Object 'New FileSystemObject
Dim R As Range
Dim C As Range
Dim Target As Object 'TextStream
Dim Line As String
' File = Application.GetOpenFilename("Text Files (*.txt), *.txt")
File = Split(ThisWorkbook.FullName, ".")
File(UBound(File)) = "txt"
File = Join(File, ".")
If File <> False Then
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Target = Fso.CreateTextFile(File)
For Each R In Range("A1:W19").Rows
For Each C In R.Cells
Select Case C.Column
Case 1: Line = C.Text
Case 11: ' Valeur sur 8 positions
Line = Line & " " & _
IIf(C = "", String(8, " "), Right(String(8, "0") & C, 8))
Case Else: Line = Line & " " & C.Text
End Select
Next
Target.writeline Line
Next
Target.Close
Set Target = Nothing
Set Fso = Nothing
End If
End Sub