Bonjour à tous,
dans le cadre de mon travail, j'écris un petit programme Excel 97 avec lequel je dois transférer les informations saisies dans un fichier .txt. Jusque là tout va bien mais j'aimerais qu'à la fin de ce fichier txt, sous le dernier enregistrement, et sur la gauche, qu'Excel dépose une fin de saisie. Je sais que le code ASCII qu'il me faut et le 26 (Substitute) mais je n'arrive pas du tout à le faire prendre en compte lors de la cloture du .txt. s'il y a une bonne âme pour m'aider. Voici le début du code et la fin.
DEBUT
Private Sub Cmdprint_Click()
Cmdprint.Visible = False
'impression feuille active
ActiveWindow.SelectedSheets.PrintOut
' TRANSFERT KGS
Dim LigNe As Variant
Dim Col As Variant
FIN
Open "\\CHEMIN\REPERTOIRE\CELLULE ASSISTANCE TEL\ADHESIONS 11à19\menp487n.txt" For Append As #1 'Ecriture dans un fichier texte
If Len(Trim(Worksheets("TRANSFERT KGS").Range("B30").Value)) <> 0 Then Print #1, Worksheets("TRANSFERT KGS").Range("B30").Value & vbCrLf
If Len(Trim(Worksheets("TRANSFERT KGS").Range("B31").Value)) <> 0 Then Print #1, Worksheets("TRANSFERT KGS").Range("B31").Value & vbCrLf
If Len(Trim(Worksheets("TRANSFERT KGS").Range("B32").Value)) <> 0 Then Print #1, Worksheets("TRANSFERT KGS").Range("B32").Value & vbCrLf
If Len(Trim(Worksheets("TRANSFERT KGS").Range("B33").Value)) <> 0 Then Print #1, Worksheets("TRANSFERT KGS").Range("B33").Value & vbCrLf
If Len(Trim(Worksheets("TRANSFERT KGS").Range("B34").Value)) <> 0 Then Print #1, Worksheets("TRANSFERT KGS").Range("B34").Value & vbCrLf
If Len(Trim(Worksheets("TRANSFERT KGS").Range("B35").Value)) <> 0 Then Print #1, Worksheets("TRANSFERT KGS").Range("B35").Value & vbCrLf
If Len(Trim(Worksheets("TRANSFERT KGS").Range("B36").Value)) <> 0 Then Print #1, Worksheets("TRANSFERT KGS").Range("B36").Value & vbCrLf
If Len(Trim(Worksheets("TRANSFERT KGS").Range("B37").Value)) <> 0 Then Print #1, Worksheets("TRANSFERT KGS").Range("B37").Value & vbCrLf
If Len(Trim(Worksheets("TRANSFERT KGS").Range("B38").Value)) <> 0 Then Print #1, Worksheets("TRANSFERT KGS").Range("B38").Value & vbCrLf
Oui le code n'est pas des plus pur et mis ici il fait trés tassé.
Merci en tout cas pour la réponse, j'ai aussi réussi ce matin à l'instaurer par
& chr$(26) 'en fin des lignes de transferts.
Par contre, maintenant je l'ai à chaques transferts d'information alors que je ne veux l'avoir qu'une seule fois, à la fin.