Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default OnAction calls to subroutine

VBA - Office97 - Excel

I have a routine which populates a worksheet with shapes (rectangles). Each
is uniquely identified with an index number appended to its name. At he same
time, the "onaction" property in set to call a common subroutine.

This subroutine needs to know which shape was clicked, but the calling
routine (i.e. the onaction statement) does not seem to support arguments.
Does anybody know how I can identify the shape in the target subroutine after
the action is triggered.

Please note that it is impractical to call a different subroutine for every
shape on the sheet - there are too many of them!

Any assistance would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default OnAction calls to subroutine

Application.Caller

--

HTH

RP
(remove nothere from the email address if mailing direct)


"TerryP" wrote in message
...
VBA - Office97 - Excel

I have a routine which populates a worksheet with shapes (rectangles).

Each
is uniquely identified with an index number appended to its name. At he

same
time, the "onaction" property in set to call a common subroutine.

This subroutine needs to know which shape was clicked, but the calling
routine (i.e. the onaction statement) does not seem to support arguments.
Does anybody know how I can identify the shape in the target subroutine

after
the action is triggered.

Please note that it is impractical to call a different subroutine for

every
shape on the sheet - there are too many of them!

Any assistance would be appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default OnAction calls to subroutine

Hi Terry,
you can use application.caller like that:

Sub ShapesInit()
Dim i%
With Worksheets(1)
For i = 1 To .Shapes.Count
..Shapes(i).OnAction = "Test"
Next i
End With
End Sub

Sub Test()
Select Case Application.Caller
Case "Rectangle 1"

Case "Rectangle 3"

'....
End Select
End Sub

Regards,
MP

"TerryP" a écrit dans le message de
...
VBA - Office97 - Excel

I have a routine which populates a worksheet with shapes (rectangles).

Each
is uniquely identified with an index number appended to its name. At he

same
time, the "onaction" property in set to call a common subroutine.

This subroutine needs to know which shape was clicked, but the calling
routine (i.e. the onaction statement) does not seem to support arguments.
Does anybody know how I can identify the shape in the target subroutine

after
the action is triggered.

Please note that it is impractical to call a different subroutine for

every
shape on the sheet - there are too many of them!

Any assistance would be appreciated.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default OnAction calls to subroutine

application.Caller should return the name of the shape that triggered the
routine

--
Regards,
Tom Ogilvy

"TerryP" wrote in message
...
VBA - Office97 - Excel

I have a routine which populates a worksheet with shapes (rectangles).

Each
is uniquely identified with an index number appended to its name. At he

same
time, the "onaction" property in set to call a common subroutine.

This subroutine needs to know which shape was clicked, but the calling
routine (i.e. the onaction statement) does not seem to support arguments.
Does anybody know how I can identify the shape in the target subroutine

after
the action is triggered.

Please note that it is impractical to call a different subroutine for

every
shape on the sheet - there are too many of them!

Any assistance would be appreciated.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default OnAction calls to subroutine

Great stuff! - works like a charm - thanks very much


"Michel Pierron" wrote:

Hi Terry,
you can use application.caller like that:

Sub ShapesInit()
Dim i%
With Worksheets(1)
For i = 1 To .Shapes.Count
..Shapes(i).OnAction = "Test"
Next i
End With
End Sub

Sub Test()
Select Case Application.Caller
Case "Rectangle 1"

Case "Rectangle 3"

'....
End Select
End Sub

Regards,
MP

"TerryP" a écrit dans le message de
...
VBA - Office97 - Excel

I have a routine which populates a worksheet with shapes (rectangles).

Each
is uniquely identified with an index number appended to its name. At he

same
time, the "onaction" property in set to call a common subroutine.

This subroutine needs to know which shape was clicked, but the calling
routine (i.e. the onaction statement) does not seem to support arguments.
Does anybody know how I can identify the shape in the target subroutine

after
the action is triggered.

Please note that it is impractical to call a different subroutine for

every
shape on the sheet - there are too many of them!

Any assistance would be appreciated.



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
Call a subroutine using variable subroutine name dhstein Excel Discussion (Misc queries) 3 July 26th 09 08:28 PM
SUBROUTINE HELP biker man Excel Discussion (Misc queries) 1 July 28th 07 04:06 PM
Every second subroutine dolegow Excel Programming 1 October 12th 03 02:11 AM
OnAction Jim Rech Excel Programming 1 September 5th 03 04:39 PM
.OnAction - Multiple Calls Matt[_9_] Excel Programming 2 August 9th 03 09:07 PM


All times are GMT +1. The time now is 08:17 AM.

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"