kharon_rp
Messages postés3Date d'inscriptionmercredi 12 avril 2006StatutMembreDernière intervention24 avril 2006
-
14 avril 2006 à 11:27
kharon_rp
Messages postés3Date d'inscriptionmercredi 12 avril 2006StatutMembreDernière intervention24 avril 2006
-
19 avril 2006 à 09:44
Bonjour,
Je voudrais créer un UserForm avec ListBox mais uniquement avec du code VBA.
michelxld
Messages postés402Date d'inscriptionvendredi 6 août 2004StatutMembreDernière intervention12 octobre 200832 16 avril 2006 à 20:56
bonsoir
j'espere que cet exemple pourra t'aider
Option Explicit
Dim Usf As Object
Sub lancementProcedure()
Dim X As Object
Dim i As Integer
Dim strList As String
strList = "ListBox1"
Set X = creationUserForm_Et_listBox_Dynamique(strList)
For i = 1 To 10
X.Controls(strList).AddItem "Donnee " & i
Next i
X.Show
ThisWorkbook.VBProject.VBComponents.Remove Usf
Set Usf = Nothing
End Sub
Function creationUserForm_Et_listBox_Dynamique(nomListe As String) As Object
Dim ObjListBox As Object
Dim j As Integer
Set Usf = ThisWorkbook.VBProject.VBComponents.Add(3)
With Usf
.Properties("Caption") = "Mon UserForm"
.Properties("Width") = 300
.Properties("Height") = 200
End With
Set ObjListBox = Usf.Designer.Controls.Add("Forms.ListBox.1")
With ObjListBox.Left 20: .Top 10: .Width = 90: .Height = 140
.Name = nomListe
.Object.ColumnCount = 1
.Object.ColumnWidths = 70
End With
With Usf.CodeModule
j = .CountOfLines
.insertlines j + 1, "Sub " & nomListe & "_Click()"
.insertlines j + 2, "If Not ListBox1.ListIndex = -1 Then MsgBox ListBox1"
.insertlines j + 3, "End Sub"
End With
VBA.UserForms.Add (Usf.Name)
Set creationUserForm_Et_listBox_Dynamique = UserForms(UserForms.Count - 1)