Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel 2000 - Events for shapes (i.e. popup shortcut menus)

Posted on 2001-08-10
3
Medium Priority
?
958 Views
Last Modified: 2008-02-01
I am trying to figure out if there is a way to make events for drawing shapes in Excel 2000.  Let me try to explain.  A worksheet has events such as "selectionchange", "beforerightclick" and "beforedoubleclick".  If I write this code into a worksheet module:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Cancel=True
End Sub

This disallows me from getting a popup shortcut menu when right clicking over a cell.  However, if I right click over a drawing shape I DO indeed get the shortcut menu.  So obviously drawing shapes are handled differently.  But the fact that a drawing shape can respond to the right click by displaying a popup menu tells me that somehow it does have events that control it.  But I have no idea of how to access any events that control a shape.  Does that make any sense?  Ultimately I want to create a custom popup shortcut menu only when right clicking on a shape and not for the cells.  Thanks for any help you can give me.

Chris
0
Comment
Question by:cpw26
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
calacuccia earned 600 total points
ID: 6374626
Hi cpw,

The shortcut menu is not raised by an event, but this inherent event is modifiable.

All right-click popup menus are part of Excel's Application.CommandBars collection.

The Shape right-click popup can be found in code by doing this:

Application.CommandBars("Shapes").ShowPopup


You can modify this CommandBar control, but only at run-time, programmatically. You need to do this then in a Workbook_Open event or something, whenever your workbook is opened, but as indicated lower below, you will have to remove them programmatically as well, or the user will be stuck with your controls.

Code below adds two blank controls on the bottom of the pop up for shapes, and shows it:

Sub Crackit()
Dim myShapePupUp As CommandBarControl
Set myShapePopUp = Application.CommandBars("Shapes")
myShapePopUp.Controls.Add
myShapePopUp.Controls.Add
myShapePopUp.ShowPopup
End Sub

However, you will have to remove your custom controls programmatically as well, by removing them when the workbook is closed.

Have fun
0
 

Author Comment

by:cpw26
ID: 6380404
Thanks once again Cal. This is exactly what I needed.  Regards.

Chris
0
 
LVL 17

Expert Comment

by:calacuccia
ID: 6381217
My Pleasure, Chris.

I learned a lot from this as well ;-)

Regards
calacuccia
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question