shortcutmenu

  • Thread starter Thread starter dj
  • Start date Start date
D

dj

I've created my own 'rightclick' menu that I have made pop-
up when I rightClick a cell. I've got the code working
but the How do I temporarily 'disappear' the shortcut menu
that regularly appears when I rightclick a cell. What's
the name of the menu (and ID...just in case I need to
restore it :| Also- is there a handy dandy ID list for
commandbars?

thanks in advance,
dj
 
DJ,

Add this code to the sheet module where you want this custom right-click
menu.

Public fCustomCell As Boolean

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If fCustomCell Then
Cancel = True 'Supress builtin Cell menu
CommandBars("newCell").ShowPopup 'Show custom version
End If
End Sub

To make your menu the new right-click menu, set the variable fCustomCell,
like so

Sheet1.fCustomCell = True

To go back to normal, unset it, like so

Sheet1.fCustomCell = False


If you want it to apply to all sheets, use this event in the ThisWorkbook
vco0de module, with the same variable and same event code

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)

End Sub

In this instance, refer to the variab le like so

ThisWorkbook.fCustom Cell = True (or False)


This code will list all commandbars in a spare worksheet

Dim cb As CommandBar
Dim i As Long

i = 1
With Worksheets(3)
For Each cb In CommandBars
Cells(i, 1).Value = cb.Name
i = i + 1
Next cb
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top