Solved

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

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Some time ago I was asked to create a VBA function that would calculate a check digit for an input number, using the following procedure: First, sum up all the individual digits in the number If that sum value has more than one digit, then sum up …
In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
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 …

757 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

22 Experts available now in Live!

Get 1:1 Help Now