This workbook has Module One having Macro to add Menu to Right Click Command.
Sub RgtMenuOn()
Dim contextMenu As CommandBar
Set contextMenu = Application.CommandBars("Cell")
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=1)
.OnAction = "DashBoard1"
.Caption = "DashBoard"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=2)
.OnAction = "F"
.Caption = "FutP"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=3)
.OnAction = "FC"
.Caption = "FC"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=4)
.OnAction = "FP"
.Caption = "FP"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=5)
.OnAction = "VC"
.Caption = "VC"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=6)
.OnAction = "VP"
.Caption = "VP"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=7)
.OnAction = "OIC"
.Caption = "OIC"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=8)
.OnAction = "OIP"
.Caption = "OIP"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=9)
.OnAction = "CDoj"
.Caption = "CDoj"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=10)
.OnAction = "PDoj"
.Caption = "PDoj"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=11)
.OnAction = "CDojHam"
.Caption = "CDojHam"
.Tag = "My_Cell_Control_Tag"
End With
With contextMenu.Controls.Add(Type:=msoControlButton, Before:=12)
.OnAction = "PDojHam"
.Caption = "PDojHam"
.Tag = "My_Cell_Control_Tag"
End With
End Sub
All Contextmenu Control under Command Bars appears above Cut, Copy etc inbuild Microsoft Office Menu items
Currently it is not grouped and such custom command bars are expanding, hence need to have it under Sub-menu, and seniors help sought.
Help -
How Do I make Three Major CommandBars Say -
1) PrepareData
2) Report Data
3) CustomReport
Such that existing Command Bars appear under item 2) Report Data, and how do I group similar Command bars to call upon Macro that would appear
under item 1) Prepare Data, and 3) CustomReport
So, when I Right Click in Excel, above Cut, Copy etc in-built command bars, only above three items appear at top, and rest of other are grouped under 2) and son on
Is there also a way to hide the default, Cut, Copy, Paste, Insert…., Delete….., Clear Contents…., Filter….., Sort…, Insert Comment…., Format Cell…., Pick from Drop Down List, Define Name…., and Hyperlink….
Something like
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
' cancel default shortcut menu
Cancel = True
'''''and call Custom Right Click Menu made above…..only to appear
'this code will be under relevant Worksheet Code window
End Sub
This Custom Right Click Menu should appear have control only in the current workbook only.
Thanks
Bookmarks