Solved

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

Posted on 2001-08-10
3
879 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 150 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 10 Modified 2 44
PC freezes and shutdowns becoming more frequent 17 106
Microsoft 365 versus MicroSoft 2013/2016 8 70
Compile Error 7 42
Problem: You created a new custom form in Outlook for your contacts (added fields, deleted fields, changed the layout of fields, whatever) and made it the default form for contacts. The good news is that all new contacts will utilize the new form. T…
This article will show you how to use shortcut menus in the Access run-time environment.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
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…

864 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now