View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
AndyT AndyT is offline
external usenet poster
 
Posts: 7
Default I have a problem with determining if a shape is selected.

To test, I have assigned macros to 3 shapes, when I click on one of these
shapes I'm not able to select it, naturally, it runs the macro.
If I select one of the shapes that have not been assigned to the macro, it
becomes selected (obviously). If I then click an assigned shape it returns
the name of the unassigned shape and not the one clicked.
When I have assigned macros to all the shapes I will not be able to select
and if no shape is selected when I click an assigned shape I get an
'Application-defined or object-defined error'.
On the bright side, I can use this code a different way. Namely, by
assigning the code to a command button, clicking and selecting any of the
shapes then the command button this would return the name as needed.
Nevertheless, I would prefer the way I thought of origially if it can be
achieved.
Thanks for your help
AndyT

"Bob Flanagan" wrote:

Try:

Dim sObj As Object
Set sObj = Selection
MsgBox sObj.Name

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"AndyT" wrote in message
...
I've formatted a worksheet to represent an office plan. I have shapes and
grouped shapes to represent assetts
What I want is to click on a shape, returning the name of the shape
selected.
I would use this name to get associated information from a database
spreadsheet.
There isn't any property 'Selected' or 'Activated' associated with the
Shape
object.
Anyone know how to do this? Any response would be much appreciated.
Using Excel2002 (10.2614.2625)
O/S XP