Customizing popup menu
VBA Telemetry pings you when your VBA projects fail
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Customizing popup menu

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    How can I customize the popup menu that comes up when you right click on any cell in a worksheet ?

  2. #2
    Guest

    Default

    On 2002-03-14 09:34, vijayvs wrote:
    How can I customize the popup menu that comes up when you right click on any cell in a worksheet ?
    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    On Error GoTo 1
    With Application.CommandBars("Cell")
    Do
    .Controls(1).Delete
    Loop
    1:
    Set temp = .Controls.Add(msoControlButton)
    temp.Caption = "Test1"
    temp.OnAction = "Routine1" 'put routine1 in regular module
    Set temp = .Controls.Add(msoControlButton)
    temp.Caption = "Test2"
    temp.OnAction = "Routine2" 'put routine2 in regular module
    End With
    End Sub

  3. #3
    Guest

    Default

    I tried this and now all that shows up is Test1 and Test2, where did the other buttons go?

  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,936
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Sorry to plagiarise Anonymous's code but try this. Just place the code in a standard module and run the macro. The two items will then be added to the shortcut menu.

    Code:
    Sub SetUpBar()
    With Application.CommandBars("Cell")
        Set temp = .Controls.Add(msoControlButton)
        temp.Caption = "Test1"
        temp.OnAction = "Routine1"    'put routine1 in regular module
        Set temp = .Controls.Add(msoControlButton)
        temp.Caption = "Test2"
        temp.OnAction = "Routine2"    'put routine2 in regular module
    End With
    End Sub


User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com