Bonsoir

J'ai une barre de Menu qui contient trois sous menu .Par contre je n'ai qu'un seul sous MENU qui apparait : Voici le code que j'ai utilisé :

Code vba : 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 
Private Sub Form_Open(Cancel As Integer)
' ==== déclaration =====
    Dim cmb As Office.CommandBar
    Dim btn As Office.CommandBarButton
    Dim subCmb As Office.CommandBarPopup
    Dim subCmb1 As Office.CommandBarPopup
    Dim subCmb2 As Office.CommandBarPopup
 
 
    On Error Resume Next
    Application.CommandBars("MaBarre").Delete
 
    ' ===== affectation =====
    Set cmb = Application.CommandBars.Add("MaBarre", msoBarTop, True, True)
 
        ' ===== ajout du sous-menu  Fichier =====
    Set subCmb = cmb.Controls.Add(msoControlPopup)
    subCmb.Caption = "Fichier"
    subCmb.Height = 60
    subCmb.Width = 200
    '  on ajoute 1 bouton au sous-menu avec une image =====
    Set btn = subCmb.Controls.Add(msoControlButton)
    With btn
        .FaceId = 25
        .Caption = "Traitement"
        .Style = msoButtonIconAndCaption
 
    End With
    'On ajoute un deuxieme bouton au premier sous menu
 
    Set btn = subCmb.Controls.Add(msoControlButton)
    With btn
        .Caption = "Pointer Les BL"
        .Style = msoButtonCaption
    End With
 
    'On ajoute un 3 eme bouton au sous premier sous menu  Fichier
 
    Set btn = subCmb.Controls.Add(msoControlButton)
    With btn
        .Caption = "Quiter"
        .Style = msoButtonCaption
    End With
 
        ' ===== ajout du 2 eme sous-menu (EX)=====
    Set subCmb1 = cmb.Controls.Add(msoControlPopup)
    subCmb.Caption = "Rapport"
    subCmb.Height = 60
    subCmb.Width = 200
 
    ' ===== on ajoute 1 bouton au sous-menu avec une image =====
    Set btn = subCmb1.Controls.Add(msoControlButton)
    With btn
        .FaceId = 25
        .Caption = "Relevé "
        .Style = msoButtonIconAndCaption
 
    End With
    ' ===== ajout du 3 eme sous-menu (Outil)=====
 
    Set subCmb2 = cmb.Controls.Add(msoControlPopup)
    subCmb.Caption = "Outils"
    subCmb.Height = 60
    subCmb.Width = 200
 
    ' on ajoute 1 bouton au sous-menu avec une image =====
    Set btn = subCmb2.Controls.Add(msoControlButton)
    With btn
        .FaceId = 25
        .Caption = "Initialiser "
        .Style = msoButtonIconAndCaption
 
    End With
 
    ' ===== rendre la barre visible =====
    cmb.Visible = True
 
End Sub

Je ne sais pourquoi , les sous menus n'apparaissent pas tout en meme temps


Merci d'avoir jeté un coup d'oeil