Option Explicit
'
Sub CreerFichierTexte()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim NouveauTexte, Valeur As String
Dim Limite, Boucle As Integer
Dim TEXTE As String
Dim oFS, NouveauFichier As Object
For Boucle = 2 To 270
NouveauTexte = ThisWorkbook.Path & "\" & Cells(Boucle, 1) & ".txt"
Set oFS = CreateObject("Scripting.FileSystemObject")
Set NouveauFichier = oFS.CreateTextFile(NouveauTexte, ForWriting)
Limite = Range("A271").End(xlUp).Row
TEXTE = ""
TEXTE = TEXTE & Cells(Boucle, 3) & Chr(13) & Cells(Boucle, 4).Value & Chr(9) & Cells(Boucle, 5).Value & Chr(13) & Cells(Boucle, 6).Value & Chr(9) & Cells(Boucle, 7).Value & Chr(13)
'MsgBox ("---" & Cells(Boucle, 8) & "--")
'If (IsEmpty(Trim(Cells(Boucle, 8).Value)) Or Not IsNull(Trim(Cells(Boucle, 8).Value) Or Not Feuil1.Cells(Boucle, 8) = "") Then
If (Feuil1.Cells(Boucle, 8) <> "") Then
TEXTE = TEXTE & Cells(Boucle, 8).Value & Chr(9) & Cells(Boucle, 9).Value & Chr(13)
End If
If (IsEmpty(Cells(Boucle, 10).Value) = False) Then
TEXTE = TEXTE & Cells(Boucle, 10).Value & Chr(9) & Cells(Boucle, 11).Value & Chr(13)
End If
If (IsEmpty(Cells(Boucle, 12).Value) = False) Then
TEXTE = TEXTE & Cells(Boucle, 12).Value & Chr(9) & Cells(Boucle, 13).Value
End If
NouveauFichier.WriteLine (TEXTE)
NouveauFichier.Close
Next Boucle
End Sub
'