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
| Option Explicit
Public Const monBouton As String = "Ma ""&super"" macro" ' le & permet d'utiliser les raccourcis clavier
Sub Ouverture()
Dim NewCtrl As Object
'Ajout d'une ligne dans le menu contextuel en 3ème position
Fermeture
With CommandBars("Cell")
Set NewCtrl = .Controls.Add(Type:=1, ID:=1, before:=3)
With NewCtrl
.Caption = monBouton
.OnAction = "Macro1"
.FaceId = 98
.Tag = "C'est bon?"
End With
End With
End Sub
Sub Fermeture()
'Suppression du bouton
On Error Resume Next
CommandBars("Cell").Controls(monBouton).Delete
On Error GoTo 0
End Sub
Sub Macro1()
MsgBox CommandBars.ActionControl.Tag
End Sub |
Partager