Solved

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

Posted on 2001-08-10
3
926 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
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 …

739 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