Results 1 to 1 of 1

Thread: Add Control to List On Right-Click

  1. #1
    Senior Member
    Join Date
    Apr 2011
    Posts
    190
    Rep Power
    14

    Add Control to List On Right-Click

    All this code is posted on a different thread -(Excel Fox - calendar control - under Ribbon code - fluent interface) - But I figured it was worth posting separately - what this code does - it adds to the list when you Right_Click on any cell on any sheet - I have used the workbook event. But you can also use the WorkSheet event - if you only want action on a single sheet.

    If you look in Excel Fox's thread - there is a link to all the various .FaceId you can use - I just messed around in the code to test it.


    ThisWorkBook
    Code:
    Option Explicit
    
    Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
        AddOnRightClick
    End Sub
    
    Private Sub AddOnRightClick()
        On Error Resume Next
     
        Dim cbrButton As CommandBarButton
        
        With Application
            .CommandBars("Cell").Controls("Sheet_Button_Testing").Delete
            Set cbrButton = .CommandBars("Cell").Controls.Add(Temporary:=True, Before:=1)
        End With
     
        With cbrButton
           .BeginGroup = True
           .Style = msoButtonIconAndCaption
           .Caption = "Sheet_Button_Testing"
           '.FaceId = 125
           '.FaceId = 17
           '.FaceId = 99
           .FaceId = 519
           .OnAction = "ShowRightClicked"
        End With
     
        Set cbrButton = Nothing
     
        On Error GoTo 0
    End Sub

    Module1
    Code:
    Option Explicit
    Public Sub ShowRightClicked()
        MsgBox "Right_Click captured - add your own code here"
    End Sub
    Last edited by Rasm; 04-17-2011 at 08:19 PM. Reason: typo
    xl2007 - Windows 7
    xl hates the 255 number

Similar Threads

  1. How to Add Custom List And Use in Custom Sorting
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 06-07-2013, 10:41 PM
  2. Replies: 1
    Last Post: 05-03-2013, 04:41 PM
  3. Double click can edition in ListView
    By marreco in forum Excel Help
    Replies: 1
    Last Post: 02-18-2013, 10:09 PM
  4. Click Run cycle
    By PcMax in forum Excel Help
    Replies: 6
    Last Post: 11-01-2011, 04:50 AM
  5. Add Control To Right-Click Cell Context Menu
    By Rasm in forum Excel Help
    Replies: 3
    Last Post: 04-17-2011, 08:04 PM

Posting Permissions

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