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
| Private Sub Workbook_BeforeOpen(Cancel As Boolean)
Dim Garantie, NouvelleAnnée As CommandBarPopup
On Error Resume Next
With Application.CommandBars(1)
Set Garantie = .Controls.Add _
(Type:=msoControlPopup, before:=.Controls.Count - 1)
End With
Garantie.Caption = "Garantie"
With Application.CommandBars(1)
Set NouvelleAnnée = .Controls.Add _
(Type:=msoControlPopup, before:=.Controls.Count - 1)
End With
NouvelleAnnée.Caption = "Nouvelle Année"
'Creation des sous-menus
With Garantie.Controls.Add(msoControlButton)
.Caption = "Feuille Garantie"
.OnAction = "ScanningExcel"
End With
With Garantie.Controls.Add(msoControlButton)
.Caption = "Garantie 2"
.OnAction = "BdSaisie"
End With
With NouvelleAnnée.Controls.Add(msoControlButton)
.Caption = "Création nouvelle année"
.OnAction = "NouvelleAnnée"
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Garantie").Delete
Application.CommandBars("NouvelleAnnée").Delete
End Sub |