Context sensitive menu options

  • Thread starter Thread starter K_Macd
  • Start date Start date
K

K_Macd

The following code adds another paste special option to the right click menu

With Application.CommandBars("Cell").Controls _
.Add(Type:=msoControlButton, before:=5, _
Temporary:=False)
.Caption = "Paste &Value" '
.OnAction = "PasteSpecValue"
.Tag = "PS_PasteValue"
.Enabled = True

End With

Is there a code action to enable or disable that option dynamically as the
clipboard status alternates between filled and empty rather than test in the
'onaction' procedure at a lower level ?

TIA
 
You can use the SheetBeforeRightClick event to check whether the clipboard
object is empty or not. If empty disable the option as below..

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)
If <object> is nothing then
Application.CommandBars("cell").Controls("controlname").Enabled = False
End If
End Sub


If this post helps click Yes
 
Back
Top