Consulting

Results 1 to 2 of 2

Thread: right-Click on image

  1. #1
    VBAX Newbie
    Joined
    Nov 2014
    Posts
    1
    Location

    Post right-Click on image

    Hello,
    I want to do an right-click on image in excel (not ActiveX controles image), for displayed a custom popup menu.

    thanks for help!

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    If it is a image, you can use code like this to add to the existing pop-up menu.
    You can even delete some of the existing items. (The .Reset method of a CommandBar object is a useful method to know, if you are going this route.)
    Note that CommandBars (including pop-up menus) and their controls (listed options) are scoped to the Application. Any changes will apply to all your workbooks. Thus, the utility of the Temporary argument when adding new controls.

    Have you considered just Assigning a Macro to the shape rather than going through a Right-Click menu?

    Sub test()
       
        Dim newControl As CommandBarControl
    
        With Application.CommandBars.FindControl(Id:=14826).Parent
          Rem with Picture Context pop-up menu
    
            Set newControl = .Controls.Add(Type:=msoControlButton, temporary:=True)
    
            With newControl
                .Visible = True
                .Caption = "test"
                .OnAction = "myMacro"
            End With
        End With
        
    End Sub
    
    Sub myMacro()
        MsgBox "hi"
    End Sub

Posting Permissions

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