Sub CreeMonBouton() Set bar = Application.CommandBars("Standard") With bar.Controls.Add(msoControlButton, , , , True) .Caption = "Ouvrir l'application" .FaceId = 9161 .Tag = 1 '.Style = msoButtonCaption' à activer pour supprimer l'icône .OnAction = "L_lancer" End With End Sub Sub L_lancer() Ma_macro End Sub Sub Ma_macro() MsgBox "Bonjour"'mettre ta macro End Sub
Sub CreeMonBouton() Set bar = Application.CommandBars("Standard") With bar.Controls.Add(msoControlButton, , , , True) .Caption = "Calculatrice" .FaceId = 960 .Tag = 1 '.Style = msoButtonCaption .OnAction = "L_Start" End With End Sub Sub L_Start() Shell "C:\WINDOWS\system32\calc.exe" End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionSub CreeMonBouton() Set bar = Application.CommandBars("Standard") With bar.Controls.Add(msoControlButton, , , , True) .Caption = "Ouvrir l'application" .FaceId = 9161 .Tag = 1 '.Style = msoButtonCaption .OnAction = "L_lancer" End With End Sub Sub L_lancer() ma macro End Sub
Option Explicit Private Sub Workbook_Open() CreeMonBouton End Sub