Re : Création d'un fichier txt
Bonjour le forum,
Le bout de code ci-dessous devrait répondre au besoin :
Public Sub P_EcrireDansFichier()
Dim L_Compteur As Long
Dim A_NomFichier As String
L_Compteur = FreeFile
'---construction du nom de fichier (à adapter si besoin)
A_NomFichier = "d:\" & Cells(ActiveCell.Row, 7) & Cells(ActiveCell.Row, 3) & ".mac"
'---Ouverture (ou création s'il n'existe pas) du fichier pour écriture
Open A_NomFichier For Append As #L_Compteur
'---Ecriture du "Monsieur"
Write #L_Compteur, Cells(ActiveCell.Row, 5)
'---Ecriture de l"adresse"
Write #L_Compteur, Cells(ActiveCell.Row, 12)
'---Fermeture du fichier
Close #L_Compteur
End Sub
Cdt, Hamcec.