Solved

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

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
My experience with Windows 10 over a one year period and suggestions for smooth operation
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

813 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

13 Experts available now in Live!

Get 1:1 Help Now