View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JW[_2_] JW[_2_] is offline
external usenet poster
 
Posts: 638
Default Displaying A custom menu as a popup menu

In the sheet module where you want the right_click menu to appear,
place something like this. You can set a For..Next loop to add as
many buttons as you may need.
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
As Boolean)
Dim cMain As CommandBarControl, btn As CommandBarControl
For Each cMain In Application.CommandBars("Cell").Controls
If cMain.Caption = "Your Caption Here" Then cMain.Delete
Next
Set cMain = Application.CommandBars("Cell").Controls.Add _
(Type:=msoControlPopup)
cMain.Caption = "Your Caption Here"
Set btn = cMain.Controls.Add
btn.Caption = "Whatver You Want"
btn.OnAction = "SomeMacro"
Set cMain = Nothing
Set btn = Nothing
End Sub

diddy_david wrote:
I've created custom a custom menu with various macros, how can I display this
as a popup (shortcut) menu when a cell is right clicked?