Bonjour,
Je souhaite créer un formulaire UserForm sur lequel se trouve un certains nombres (variable) de boutons paramétrables depuis une feuille Excel.
J'ai déjà réussi à créer les boutons.
A présent, je souhaite affecter des actions à ses boutons mais lorsque j'écris le code ci-dessous, rien ne se passe.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 for i = 1 To Nbouton couleurFond = Cells((Caisse.numBouton - 1) * nbrOptionBouton + posCouleurFond, i * 3 + 3).Interior.Color couleurTexte = Cells((Caisse.numBouton - 1) * nbrOptionBouton + posCouleurTexte, i * 3 + 3).Interior.Color If i Mod X = 0 Then posX = X Else posX = i Mod X End If posY = Application.WorksheetFunction.RoundUp(i / X, 0) Set sousBouton(i) = Controls.Add("Forms.CommandButton.1") With sousBouton(i) .Name = "sousBouton" & i .Caption = Cells((Caisse.numBouton - 1) * nbrOptionBouton + posCaptionBouton, i * 3 + 3) .Left = interBouton + (interBouton + wthBouton) * (posX - 1) .Top = interBouton + (interBouton + hgtBouton) * (posY - 1) .Width = wthBouton .Height = hgtBouton .BackColor = couleurFond .ForeColor = couleurTexte End With Next
Avez-vous une idée svp ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 Private Sub sousBouton1_Click() sousBoutons_Click (1) End Sub Private Sub sousBouton2_Click() sousBoutons_Click (2) End Sub ...
Merci d'avance,
Cordialement,
--
GLMDRX
Partager