View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
avveerkar[_32_] avveerkar[_32_] is offline
external usenet poster
 
Posts: 1
Default Shapes object events?


Don't be sorry...I'm very happy that someone is interested in my
problem. I'll try again. I have a procedure which import DXF (AutoCad)
into Excel. Lines in Autocad becomes Lines in Excel. I can draw any
Number of lines in Autocad so I don't know for their number till I run
procedure which import DXF in Excel. Now I have their number and the
procedure already draw them all (in Excel). But here the main problem
appear: how can I assign a macro to all lines by VBA. I can do this
manual (clik first line, assign macro, click second...like you suggest
in first reply). I want to VB do that for all lines.
Dr.Ile

I was away for two days hence could not respond to your mail. Again sorry
for that. Now I understand your problem. I have never worked with DXF. But
as I understand when when you a group of lines from CAD to EXCEL each line
is represented as indivsual drawing object in EXCEL. Suppose there are 10
lines. There are two possibilities. You want to assign only one procedure
to all the 10 lines. That means if you click on any line ( each line is
now clickable ) one procedure needs to be executed. I assume that these
lines are imported as Shapes objec collection in EXCEL. ( I am assuming
this because all drawing objects such as images, cliparts, lines and
figures drawn on worksheet form a Shapes collection ). In that case a
simple procedure to select all the shapes on the sheet and assign a
procedure could be
Private Sub AssgnProcToLines()
ActiveSheet.Shapes.SelectAll
Selection.OnAction = "MyProcedure"
End Sub
This will make all the shapes on the sheet clickable and I am assuming
that there are only lines as objects. In case you want to assign
different proc to indivisual ( doesn't seem likely )then you need have
those different procedures named as, say, myproc1, myproc2,myproc3 etc
and want to assign first one to line 1, second to line 2 etc Then your
proc could be

For i = 1 to 10
ActiveSheet.Shapes(i).select
Selection.OnAction ="myproc" & i
Next
If you have many other shapes on the worksheet othere than the lines and
want to make only the lines clickable then you need to find out how these
lines are identified by EXCEL as member of Shapes colletion. They could be
pictures, lines etc One qucikest method is to record a macro select these
lines one by one and then read the macro code to find out how EXCEL
identifies the lines.

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