PDA

View Full Version : Add Control To Right-Click Cell Context Menu



Rasm
04-17-2011, 05:36 AM
Excel Fox
Down loaded your calendar - thanks - how did you add the Calendar choice when you right_click on a cell _ I posted that question on MrExcel - never got any answers - can you show that piece of code?

Thanks

Excel Fox
04-17-2011, 07:07 AM
Here's the code Rasm



Private Sub AddOnRightClick()
On Error Resume Next

Dim cbrButton As CommandBarButton

With Application
.CommandBars("Cell").Controls("Calendar").Delete
Set cbrButton = .CommandBars("Cell").Controls.Add(Temporary:=True, Before:=1)
End With

With cbrButton
.BeginGroup = True
.Style = msoButtonIconAndCaption
.Caption = "Calendar"
.FaceId = 125
.OnAction = "ShowCalendar"
End With

Set cbrButton = Nothing

On Error GoTo 0
End Sub




Private Sub DeleteOnRightClick()
On Error Resume Next

With Application
.CommandBars("Cell").Controls("Calendar").Delete
End With

On Error GoTo 0

End Sub

Rasm
04-17-2011, 07:38 PM
Cool - this works nicely - sweet.

Rasm
04-17-2011, 08:04 PM
Here is a link to a bunch of different .FaceId values.

http://www.outlookexchange.com/articles/toddwalker/BuiltInOLKIcons.asp