Copie du contenu d'une TextBox vers un txt
l
Bonjour,
je souhaiterais créer un fichier txt à partir des données dans les textbox, mais sans succès
Voici le code:
Sub sortie()
Dim TheText As String
Dim TheFile As Variant
TheFile = ThisWorkbook.Path & "\COMMANDES.txt"
If TheFile = False Then Exit Sub
'si le fichier est ouvert
Open TheFile For Output As #1
TheText_1 = "Nom et prénom du collaborateur: " & TextBox7.SelectedValue.ToString()
TheText_2 = "Direction: " & ComboBox2.Text
TheText_3 = "Métier: " & ComboBox1.Text
TheText_4 = "Date de sortie: " & DTPicker1.Text
TheText_5 = "Materiel à rendre: " & TextBox56.Text
TheText_6 = "Commentaire : " & TextBox55.Text
Print #1, TheText_1 & ""; vbCrLf & TheText_2 & "" & vbCrLf & TheText_3 & ""; vbCrLf & TheText_4 & ""; vbCrLf & TheText_5 & ""; vbCrLf & TheText_6 & "";
Close
Exit Sub
Out:
Close
End Subpouvez vous m'aider svp.
merci d'avance
Invité
Bonjour lucianaa
Essaye avec ".value" au lieu de ".text"
TheText_1 = "Nom et prénom du collaborateur: " & TextBox7.Value
TheText_2 = "Direction: " & ComboBox2.Value
TheText_3 = "Métier: " & ComboBox1.Value
TheText_4 = "Date de sortie: " & DTPicker1.Value
TheText_5 = "Materiel à rendre: " & TextBox56.Value
TheText_6 = "Commentaire : " & TextBox55.ValueIl faut évidemment que ce code soit dans ton USF
A+