Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Général VBA
Général VBA Forum général VBA . Pour les logiciels spécifiques (Access, Excel, Word, ...), postez dans les bons sous forums.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 05/05/2007, 22h55   #1
Invité de passage
 
Inscription : mai 2007
Messages : 3
Détails du profil
Informations forums :
Inscription : mai 2007
Messages : 3
Points : 1
Points : 1
J'aimerais pouvoir créer plusieurs boutons sur un userform dynamiquement sans en connaitre le nombre auparavant et y pouvoir associer un évenement different pour chacun d'eux.
Est ce possible ? si oui, pouvez vous m'aider ?
Merci d'avance.
niko7as est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2007, 23h11   #2
Responsable Visual Basic
 
Avatar de bbil
 
Inscription : juin 2003
Messages : 11 776
Détails du profil
Informations personnelles :
Âge : 45
Localisation : France, Ariège (Midi Pyrénées)

Informations forums :
Inscription : juin 2003
Messages : 11 776
Points : 16 857
Points : 16 857
Envoyer un message via Skype™ à bbil
tu peu t'inspirer de :

Module de Classe, simulation VBA d'un groupe de contrôle




bbil est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/05/2007, 06h14   #3
Rédacteur
 
Homme michel Tanguy
Inscription : août 2005
Messages : 3 317
Détails du profil
Informations personnelles :
Nom : Homme michel Tanguy
Localisation : France, Isère (Rhône Alpes)

Informations professionnelles :
Secteur : Industrie

Informations forums :
Inscription : août 2005
Messages : 3 317
Points : 10 706
Points : 10 706
bonjour

Tu trouveras aussi une autre méthode dans ce lien:
(chapitre V-A)

http://silkyroad.developpez.com/VBA/...icEditor/#LV-A


bonne journée
michel
SilkyRoad est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/05/2007, 08h55   #4
Invité de passage
 
Inscription : mai 2007
Messages : 3
Détails du profil
Informations forums :
Inscription : mai 2007
Messages : 3
Points : 1
Points : 1
Par défaut Merci

Merci pour vos reponses.
Je vais essayer de m'inspirer du deuxieme, ca correspond plus a ce que je cherche. J'ai oublié de préciser que je travaillais sur Excel 97. Je suis en train de realiser un fichier qui permettra de gerer des stocks de produit finis.
Je vous tient au courant de l'évolution et du fonctionnement de mon projet.
Bonne journée.
niko7as est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/05/2007, 09h52   #5
Inactif
 
Avatar de ouskel'n'or
 
Inscription : février 2005
Messages : 12 466
Détails du profil
Informations forums :
Inscription : février 2005
Messages : 12 466
Points : 11 930
Points : 11 930
Selon l'utilisation, tu n'es pas obligé de passer par un module de class, tu peux aussi tester ça en mettant un bouton CommandButton1 sur un userform tout nu... (testé sur 97)
'Nécessite d'activer la réference "Microsoft Visual Basic for Applications extensibility x.x"

Code :
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Public WithEvents BoutonWithEvents As ToggleButton
Public WithEvents Bouton2WithEvents As ToggleButton
 
Private Sub Bouton2WithEvents_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    MsgBox "Bouton 2"
    Bouton2WithEvents = False
End Sub
 
Private Sub BoutonWithEvents_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    MsgBox "Bouton 1"
    BoutonWithEvents = False
End Sub
 
Sub CommandButton1_Click()
  Set BoutonWithEvents = Me.Controls.Add("Forms.ToggleButton.1", "", True)
  With BoutonWithEvents
        .Left = 30
        .Top = 50
        .Width = 100
        .Height = 40
        .Caption = "C'est le bouton 1"
  End With
 
  Set Bouton2WithEvents = Me.Controls.Add("Forms.ToggleButton.1", "", True)
  With Bouton2WithEvents
        .Left = 30
        .Top = BoutonWithEvents.Top + 50
        .Width = 100
        .Height = 40
        .Caption = "C'est le bouton 1"
  End With
  CommandButton1.Visible = False
End Sub
 
Private Sub UserForm_Initialize()
    With CommandButton1
        .Width = 100
        .Height = 40
        .Top = 108
        .Left = 130
        .Caption = "LeBoutonQuiCrée"
        .Font.Bold = True
    End With
End Sub
Comme pour la méthode proposée par SilkyRoad, tu peux ajouter le code des boutons par soft.
ouskel'n'or est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/05/2007, 16h12   #6
Invité de passage
 
Inscription : mai 2007
Messages : 3
Détails du profil
Informations forums :
Inscription : mai 2007
Messages : 3
Points : 1
Points : 1
Par défaut Un grand merci !!!!

Merci encore a tous ceux qui m'ont repondu. J'ai resolu mon probleme avec le lien proposé par SilkyRoad. J'ai plus qu'a finaliser deux ou trois truc et j'ai fini mon fichier-apli. C'est mon chef qui va etre content et ..... a moi l'augmentation ! lol
Bonne continuation a tous !
niko7as est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 10h41.


 
 
 
 
Partenaires

Hébergement Web