Results 1 to 4 of 4

Custom Right Click Menu and Sub-menu (disable inbuilt right click menu item)

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-17-2013
    Location
    Asia
    MS-Off Ver
    Excel 2021
    Posts
    273

    Custom Right Click Menu and Sub-menu (disable inbuilt right click menu item)

    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
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 02-17-2017, 04:50 PM
  2. Custom right click menu item inside catalogue doesn't work
    By Temporary-Failure in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2015, 05:32 AM
  3. A macro to right click a cell and select a item from the right click menu?
    By Peavey in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-13-2014, 10:55 AM
  4. Persistent custom right-click shortcut menu item
    By ahartman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2009, 01:21 PM
  5. [SOLVED] Add menu item to right-click menu
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2006, 05:35 AM
  6. Adding Sub Menu Item to Current Custom Menu
    By Renato in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2005, 08:55 PM
  7. [SOLVED] disable right click menu
    By JT in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-01-2005, 01:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1