bonjour
j'ai créé une frame a l'ouverture de mon userform ( gestion de stock)
et en fonction du nombre de ligne d'e mon fichier excel ( nomenclature), je voudrais dupliquer la frame ( autant de frame que de ligne )
je n ai jamais cree de userform de maniere dynamique et j'aurais besoin d"aide
dans le code ci dessous la frame et cree mais je n'arrive pas a faire un copier coller
par la suite
il faudra que je remplisse les labels box avec les infos du fichier
une fois que la personnes aura rempli le formulaire , je devrais en faire un fichier csv
il faudra , je pense , gerer un module de classe ( pour les differents textbox , optionbox et command box )
et le module de classe , je découvre
quelqu un pourrais m'aider svp , en commencant par la duplication du frame ( une chose a la fois )
d'avance un grand merci
Private Sub UserForm_INITIALIZE()
Dim Bouton As MSForms.CommandButton
Dim Fr As MSForms.Frame
Dim cb As MSForms.CommandButton
Dim Lb As MSForms.Label
Dim chb As MSForms.CheckBox
Dim txb As MSForms.TextBox
Dim ob As MSForms.OptionButton
Dim ob2 As MSForms.OptionButton
'----- Initialise l'userform ---------------
Me.BackColor = &H800000
Me.Height = 700
Me.Width = 500
Me.Caption = " gestion des transfert de stock "
'------ Créer le Frame1 ---------------------
Set Fr = Me.Controls.Add("Forms.frame.1", "Frame1", True)
With Fr
.Left = 6
.Top = 6
.Width = 400
.Height = 35
'Fr.BackColor = &HFFC0FF
.BorderStyle = fmBorderStyleSingle
.BorderColor = &HFFFFFF
End With
'------ Créer le commandbutton ------------------
Set cb = Fr.Controls.Add("Forms.commandbutton.1", "commandbutton1", True)
With cb
.Left = 3
.Top = 8
.Width = 18
.Height = 18
End With
''------ Créer le Label ---------------------
Set Lb = Fr.Controls.Add("Forms.Label.1", "Label1", True)
With Lb
.Left = 30
.Top = 8
.Width = 192
.Height = 18
.AutoSize = False
.BackStyle = 1
.BorderColor = &H80000006
.BackColor = &HFFFFFF
.BorderStyle = fmBorderStyleSingle
.FontSize = 10
.FontBold = True
.TextAlign = fmTextAlignCenter
.Caption = "code"
End With
'------ Créer le checkbox ---------------------
Set chb = Fr.Controls.Add("Forms.checkbox.1", "checkbox1", True)
With chb
.Left = 250
.Top = 8
End With
'------ Créer le textbox ---------------------
Set txb = Fr.Controls.Add("Forms.textbox.1", "textbox1", True)
With txb
.Left = 270
.Top = 8
.Width = 50
.Height = 18
End With
'------ Créer le optionbutton ---------------------
Set ob = Fr.Controls.Add("Forms.OptionButton.1", "OptionButton1", True)
With ob
.Left = 330
.Top = 2
.Width = 80
.Height = 15
.Caption = "NEUF"
.ForeColor = &HFFFFFF
End With
Set ob2 = Fr.Controls.Add("Forms.OptionButton.1", "OptionButton2", True)
With ob2
.Left = 330
.Top = 18
.Width = 80
.Height = 15
.Caption = "REFURB"
.ForeColor = &HFFFFFF
End With
end sub
Partager