Combobox
Résolu
Titaniania
Messages postés
9
Date d'inscription
Statut
Membre
Dernière intervention
-
Titaniania Messages postés 9 Date d'inscription Statut Membre Dernière intervention -
Titaniania Messages postés 9 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Avant l'enregistrement d'un fichier traiter par ma macro, j'utilise un userfrom ("fversion") pour avoir une fenêtre avec : le message "choisissez la version de votre fichier" et une liste déroulante ["a", "b", "c"...].
J'ai un ComboBox1 :
Private Sub ComboBox1_Change()
ComboBox1.AddItem ""
ComboBox1.AddItem "A"
ComboBox1.AddItem "B"
ComboBox1.AddItem "C"
ComboBox1.AddItem "D"
ComboBox1.AddItem "E"
ComboBox1.AddItem "F"
ComboBox1.ListIndex = 0
ComboBox1.ListName = "listelettre"
End Sub
Un userfrom :
Private Sub fversion_Initialize()
ComboBox1.Clear
ComboBox1.List = Range("listelettre").Value
End Sub
et dans ma macro :
le code de traitement et ....
'Enregistrement'
With objSaveBox
'Fenetre choix de version
Call fversion_Click
'Enregistrement avec le bon nom
lettre = fversion.ComboBox1.Value
ActiveWorkbook.SaveAs Filename:=Format(Date, "yyyymmdd") & lettre & " - 2 - Injection habilitations SCALER" & ".txt", FileFormat:=xlTextWindows, Local:=True
'On stock l'adresse du fichier
adresseFichierInjection = ActiveWorkbook.FullName
End With
'Wb.Close
Workbooks(Format(Date, "yyyymmdd") & lettre & " - 2 - Injection habilitations SCALER" & ".txt").Close SaveChanges:=False
Next
Application.ScreenUpdating = True
Private Sub fversion_Click():
fversion.Show
End Sub
Ma fenêtre s'affiche mais la liste déroulante est vide. Une idée ?
Merci
Avant l'enregistrement d'un fichier traiter par ma macro, j'utilise un userfrom ("fversion") pour avoir une fenêtre avec : le message "choisissez la version de votre fichier" et une liste déroulante ["a", "b", "c"...].
J'ai un ComboBox1 :
Private Sub ComboBox1_Change()
ComboBox1.AddItem ""
ComboBox1.AddItem "A"
ComboBox1.AddItem "B"
ComboBox1.AddItem "C"
ComboBox1.AddItem "D"
ComboBox1.AddItem "E"
ComboBox1.AddItem "F"
ComboBox1.ListIndex = 0
ComboBox1.ListName = "listelettre"
End Sub
Un userfrom :
Private Sub fversion_Initialize()
ComboBox1.Clear
ComboBox1.List = Range("listelettre").Value
End Sub
et dans ma macro :
le code de traitement et ....
'Enregistrement'
With objSaveBox
'Fenetre choix de version
Call fversion_Click
'Enregistrement avec le bon nom
lettre = fversion.ComboBox1.Value
ActiveWorkbook.SaveAs Filename:=Format(Date, "yyyymmdd") & lettre & " - 2 - Injection habilitations SCALER" & ".txt", FileFormat:=xlTextWindows, Local:=True
'On stock l'adresse du fichier
adresseFichierInjection = ActiveWorkbook.FullName
End With
'Wb.Close
Workbooks(Format(Date, "yyyymmdd") & lettre & " - 2 - Injection habilitations SCALER" & ".txt").Close SaveChanges:=False
Next
Application.ScreenUpdating = True
Private Sub fversion_Click():
fversion.Show
End Sub
Ma fenêtre s'affiche mais la liste déroulante est vide. Une idée ?
Merci
3 réponses
Bonjour,
Voir ceci:
https://silkyroad.developpez.com/VBA/ControlesUserForm/#LII-F
Voir ceci:
https://silkyroad.developpez.com/VBA/ControlesUserForm/#LII-F
Titaniania
J'ai déjà lu ce site, j'ai du passé a côté de quelque chose x), je tourne en rond depuis 2 h.
Je ne sais pas où tu as trouvé cela!
Cette propriété n'existe pas;
Le code pour charger la ComboBox est à mettre comme ceci:
@+ Le Pivert
ComboBox1.ListName = "listelettre"
Cette propriété n'existe pas;
Le code pour charger la ComboBox est à mettre comme ceci:
Private Sub UserForm_Initialize() ComboBox1.AddItem "" ComboBox1.AddItem "A" ComboBox1.AddItem "B" ComboBox1.AddItem "C" ComboBox1.AddItem "D" ComboBox1.AddItem "E" ComboBox1.AddItem "F" ComboBox1.ListIndex = 1 End Sub
@+ Le Pivert
On t'a déjà répondu sur le sujet. Pourquoi ne pas suivre les conseils qui te sont donnés!
https://forums.commentcamarche.net/forum/affich-34061741-liste-deroulante-vba#p34062144
https://forums.commentcamarche.net/forum/affich-34061741-liste-deroulante-vba#p34062144