View Full Version : right-Click on image
lcwalis
12-07-2014, 12:57 AM
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!
mikerickson
12-07-2014, 09:50 AM
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.