La façon "hard" (je te la recommande fortement puisque ta CommandBar peut être re-créée)
Dans un module public tu créé la CmdBar (c'est un "one shot"):
Code :
Public Sub CreateCmdBar()
Dim cmb As CommandBar
Dim ctl As CommandBarControl
Const CMB_NAME = "MaCmdBar"
On Error Resume Next
Set cmb = CommandBars(CMB_NAME)
'Supprime la barre si elle existe déjà
If Err.Number = 0 Then
CommandBars(CMB_NAME).Delete
End If
Set cmb = CommandBars.Add(CMB_NAME)
On Error GoTo 0
With cmb
.Position = msoBarTop
.Visible = True
End With
'Ajoute un bouton...
Set ctl = cmb.Controls.Add(msoControlButton, 1)
With ctl
.FaceId = 59
.Style = msoButtonIconAndCaptionBelow
.Caption = "Coucou!"
.Visible = True
End With
Set ctl = Nothing
Set cmb = Nothing
End Sub
Dans ton formulaire tu utilise tes boutons ainsi:
Code :
Private WithEvents cmbCouCou As CommandBarButton
Private Sub cmbCouCou_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
MsgBox "Coucou!"
End Sub
Private Sub Form_Open(Cancel As Integer)
Set cmbCouCou = CommandBars("MaCmdBar").Controls("Coucou!")
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set cmbCouCou = Nothing
End Sub
_________________
HTH

This posting is provided "AS IS" with no warranties, and confers no rights cr*sse!