Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Shape Names

  Asked By: Diane    Date: Nov 30    Category: MS Office    Views: 1745
  

I can code a shape to be drawn witha name.
Set sh = ActiveSheet.Shapes.AddShape(1, 120, 60, 45, 25)
sh.Name = "two"

and I can give it a name from a cell.

Text = Cells(1, 1)
Set sh = ActiveSheet.Shapes.AddShape(1, 60, 60, 45, 25)
sh.Name = Text

what I want to do is draw connectors between my named shapes.

This works:
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 216#,
151.5, 41.25, _
3.75).Select
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadTriangle
Selection.ShapeRange.Flip msoFlipHorizontal
Selection.ShapeRange.Flip msoFlipVertical
Selection.ShapeRange.ConnectorFormat.BeginConnect
ActiveSheet.Shapes("two"), 4
Selection.ShapeRange.ConnectorFormat.EndConnect ActiveSheet.Shapes
("three"), 2

This won't!
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 216#, 151.5,
41.25, _
3.75).Select
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadTriangle
Selection.ShapeRange.Flip msoFlipHorizontal
Selection.ShapeRange.Flip msoFlipVertical
Selection.ShapeRange.ConnectorFormat.BeginConnect
ActiveSheet.Shapes(Text), 4
Selection.ShapeRange.ConnectorFormat.EndConnect ActiveSheet.Shapes
("two"), 2

So how can I draw lines between shapes named with a variable???

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Leonard Pierce     Answered On: Nov 30

It works fine on my sytem, both blocks of code.
What error is coming up?

 
Answer #2    Answered By: Elisabeth Bell     Answered On: Nov 30

It seems to work for me this evening.
I think it only works "first time".
It fails if I don't delete the old shapes  - presumably I'm trying to
give a new object a name of an exisiting oblect.

 
Didn't find what you were looking for? Find more on Shape Names Or get search suggestion and latest updates.




Tagged: