LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Shapes object events?

I haven't read all this discussion but propbably easier to have just the one
macro

Sub MyProc()
Dim shp As Shape
Dim s As String, n As Long
s = Application.Caller

' assuming names like "Line x"
n = Val(Mid$(s, 5, 5))

Set shp = ActiveSheet.Shapes(Application.Caller)

Stop
'press Alt-v, s
'Look "shp" in Locals for properties that can be returned

'maybe
'Select case n ' etc

End Sub

Sub setup()
Dim oLine As Line
For Each oLine In ActiveSheet.Lines

oLine.OnAction = "myProc"
Next
End Sub


Regards,
Peter T

"avveerkar" wrote
in message ...

Dr.Ile Wrote:
Thank you AVeerkar again, you show me the right way (I want to assign
different proc to individual lines - myproc1, myproc2,myproc3 etc). I
also ruminated abbout OnAction method and now I'm sure that this is it!
I have only one question:
As I already wrote, the number of lines is unknown (till the DXF is
imported) and consecutive the number of macro myproc1, myproc2,myproc3
etc. Do you suggest to write approx. 500 macros, soo last macro will be
myproc500 (I work with approx. 400 lines). With 500 macros I’ll capture
all possible lines. Is there onother way. I read that’s possible to
write I macro with VBA, but...:).

Dr.ile


Yes choose a large number ( say 500 ) to cover the actual number of
lines you may have. After the procedure assigns macro to the last line,
when it tries to assign a macro to a new line which does not exist, it
will give an error. Trap that error with On Error Exit Sub. This could
be your first line of the sub before you enter For..Next loop to assign
macros to different lines. Thus your sub would be
Sub AssgnMacro()
On Error Exit Sub
For i = 1 to 500
ActiveSheet.Shapes(i).select
Selection.OnAction ="myproc" & i
Next
End Sub

There would be error on two counts -either when it tries to assign proc
to a non-existant line or tries to assign a proccedure which does not
exist. It means that you must have enough number of procedures (
Myproc1 to Myproc500 ) to cover maximum number of lines you may
actually have. Since we are now only exiting on error, if number of
procedures is less than you actually require, the sub will just exit
without assigning any macro to last lines and there wont be any
indication.

A V Veerkar


--
avveerkar
------------------------------------------------------------------------
avveerkar's Profile:

http://www.excelforum.com/member.php...o&userid=30338
View this thread: http://www.excelforum.com/showthread...hreadid=506688



 
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
OnAction events intermittently failing on Shapes in Dialogsheets BizMark Excel Discussion (Misc queries) 0 August 12th 05 01:24 PM
Shapes and Events and Custom Menue Tom G.[_2_] Excel Programming 2 January 17th 05 06:37 PM
XL2000: Shape object events GSQUARED Excel Programming 1 October 22nd 03 05:15 PM
Events on shapes Christof De Backere Excel Programming 1 September 2nd 03 03:35 PM
trapping click events on shapes Matt I Excel Programming 3 August 15th 03 08:17 PM


All times are GMT +1. The time now is 05:23 AM.

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

About Us

"It's about Microsoft Excel"