Custom Right Click -->Kinda like a modified menu command


Posted by GLITZ on January 02, 2001 5:26 PM

Is there a way to add a command to the menu that comes up when I right click?

Specifically I want to add 4 fill colors to the right click menu.....


And Suggestions???
Thanks



Posted by Tim Francis-Wright on January 03, 2001 11:45 AM

This is from http://www.microsoft.com/officedev/articles/Opg/004/004.htm -- I used it in an application here
at work.

Good luck!

' adds a menu item that runs MyMacro when the
' user right-clicks in cells B1:B10
'
' put code under ThisWorkbook object under
' Workbook_SheetBeforeRightClick
' to run workbook-wide, or put in a specific
' sheet object
'
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)
For Each icbc In Application.CommandBars("cell").Controls
If icbc.Tag = "brccm" Then icbc.Delete
Next icbc
If Not Application.Intersect(Target, Range("b1:b10")) Is Nothing Then
With Application.CommandBars("cell").Controls _
.Add(Type:=msoControlButton, before:=6, _
temporary:=True)
.Caption = "New Context Menu Item"
.OnAction = "MyMacro"
.Tag = "brccm"
End With
End If
End Sub