1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
'modifie le clic droit seulement pour la colonne de droite
If Target.Column = 1 And Target.Row <> 1 And Target.Value <> "" Then
'supprime tous les éléments du clic droit
For Z = 1 To CommandBars("Cell").Controls.Count
With CommandBars("Cell")
.Controls(Z).Visible = False
End With
Next
'crée un élément
With Application.CommandBars("Cell").Controls.Add(msoControlButton)
.Caption = "Bon de commande"
.BeginGroup = True
.OnAction = "BonDeCommande"
End With
Else
Application.CommandBars("Cell").Reset
End If
End Sub |
Partager