Context sensitive menu options



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

With Application.CommandBars("Cell").Controls _
.Add(Type:=msoControlButton, before:=5, _
.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 ?


Jacob Skaria

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question