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
| Private Sub InitMenu()
Dim cbCourant As CommandBar
Dim cbpReporting As CommandBarPopup
Dim cbReporting As CommandBar
Dim Dummy As String
' s'il n'y a pas de menus installés, on quitte l'application.
If CommandBars.Count = 0 Then
MsgBox "pas de menu installés"
Application.Quit
End If
Set cbCourant = CommandBars.ActiveMenuBar
' on vérifie que le menu n'existe pas déjà
On Error Resume Next
Dummy = cbCourant.Controls("Reporting").Caption
If Err.Number = 0 Then
' le menu existe déjà : on sort
Exit Sub
End If
On Error GoTo 0
Set cbpReporting = cbCourant.Controls.Add( _
Type:=msoControlPopup, Temporary:=True)
cbpReporting.Caption = "&Reporting"
Set cbReporting = cbpReporting.CommandBar
AddMenuItem Cb:=cbReporting, Legende:="&Charger", Appel:="AppelCharger", BeginGroupFlag:=False
AddMenuItem Cb:=cbReporting, Legende:="&Vérifier", Appel:="AppelVerifier", BeginGroupFlag:=False
AddMenuItem Cb:=cbReporting, Legende:="C&onsolider", Appel:="AppelConsolider", BeginGroupFlag:=True
AddMenuItem Cb:=cbReporting, Legende:="C&lôturer", Appel:="AppelCloturer", BeginGroupFlag:=False
End Sub
Private Sub AddMenuItem(Cb As CommandBar, Legende As String, _
Appel As String, BeginGroupFlag As Boolean)
Dim cbbNew As CommandBarButton
Set cbbNew = Cb.Controls.Add(Type:=msoControlButton, Temporary:=True)
With cbbNew
.Caption = Legende
.OnAction = Appel
.BeginGroup = BeginGroupFlag
End With
End Sub |
Partager