Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Which Shape Ran The Macro?


Excel 2003/XP (soon to be Excel 2007/Vista :(

Situation: Have a workbook with lots of shapes on various worksheets
- all of which need to run essentially the same macro when they are
clicked - it could be the exact same macro, if there was some way for
the macro code to know which shape called it.

The blindingly obvious creation of a separate macro for each shape is
more than I can expect the end-users to know how (or remember) to do;
a sad situation, but factual.

Application.Caller doesn't work for shapes and I'm running out of
good ideas to try. Since clicking on a shape doesn't select it, I
can't use the .Selected property...

Is this one of those "Well, who would want to do that?" things that MS
either decided to ignore or never thought of - or has someone cracked
this particular nut?

Any help most gratefully accepted!

James

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Which Shape Ran The Macro?

Hi James,

Application.Caller doesn't work for shapes


It does !

in the macro assigned to the shape's On Action property -

Dim sCaller As String
sCaller = Application.Caller
MsgBox sCaller

' Select Case sCaller
'' etc

Regards,
Peter T

wrote in message
oups.com...

Excel 2003/XP (soon to be Excel 2007/Vista :(

Situation: Have a workbook with lots of shapes on various worksheets
- all of which need to run essentially the same macro when they are
clicked - it could be the exact same macro, if there was some way for
the macro code to know which shape called it.

The blindingly obvious creation of a separate macro for each shape is
more than I can expect the end-users to know how (or remember) to do;
a sad situation, but factual.

Application.Caller doesn't work for shapes and I'm running out of
good ideas to try. Since clicking on a shape doesn't select it, I
can't use the .Selected property...

Is this one of those "Well, who would want to do that?" things that MS
either decided to ignore or never thought of - or has someone cracked
this particular nut?

Any help most gratefully accepted!

James



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Which Shape Ran The Macro?

James,
"Application.Caller doesn't work for shapes "

In my version of Excel "Application.Caller" returns the name of the shape
that called the macro... "AutoShape 1"
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



wrote in message
Excel 2003/XP (soon to be Excel 2007/Vista :(
Situation: Have a workbook with lots of shapes on various worksheets
- all of which need to run essentially the same macro when they are
clicked - it could be the exact same macro, if there was some way for
the macro code to know which shape called it.

The blindingly obvious creation of a separate macro for each shape is
more than I can expect the end-users to know how (or remember) to do;
a sad situation, but factual.

Application.Caller doesn't work for shapes and I'm running out of
good ideas to try. Since clicking on a shape doesn't select it, I
can't use the .Selected property...

Is this one of those "Well, who would want to do that?" things that MS
either decided to ignore or never thought of - or has someone cracked
this particular nut?

Any help most gratefully accepted!

James

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Which Shape Ran The Macro?

Application.Caller doesn't work for shapes and I'm running out of

This is only working for Forms controls

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message oups.com...

Excel 2003/XP (soon to be Excel 2007/Vista :(

Situation: Have a workbook with lots of shapes on various worksheets
- all of which need to run essentially the same macro when they are
clicked - it could be the exact same macro, if there was some way for
the macro code to know which shape called it.

The blindingly obvious creation of a separate macro for each shape is
more than I can expect the end-users to know how (or remember) to do;
a sad situation, but factual.

Application.Caller doesn't work for shapes and I'm running out of
good ideas to try. Since clicking on a shape doesn't select it, I
can't use the .Selected property...

Is this one of those "Well, who would want to do that?" things that MS
either decided to ignore or never thought of - or has someone cracked
this particular nut?

Any help most gratefully accepted!

James

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Which Shape Ran The Macro?

"Ron de Bruin" wrote in message
Application.Caller doesn't work for shapes and I'm running out of


This is only working for Forms controls


Works with Shapes for me, eg Rectangle, not sure about XL2007

Regards,
Peter T




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Which Shape Ran The Macro?

Sorry, I misread (I was thinking about buttons)


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Peter T" <peter_t@discussions wrote in message ...
"Ron de Bruin" wrote in message
Application.Caller doesn't work for shapes and I'm running out of


This is only working for Forms controls


Works with Shapes for me, eg Rectangle, not sure about XL2007

Regards,
Peter T


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Shape Macro Lenny Excel Discussion (Misc queries) 0 May 19th 08 10:50 PM
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 PM
Assigning Macro To Shape Tommi[_2_] Excel Programming 2 October 31st 03 10:58 AM
Deleting a shape and the cell contents the shape is in. Dave Peterson[_3_] Excel Programming 1 October 9th 03 03:36 PM
Deleting a shape and the cell contents the shape is in. Tom Ogilvy Excel Programming 0 October 9th 03 03:43 AM


All times are GMT +1. The time now is 01:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"