ConnectorElbow or arrow completely vertical or horizontal between 2 shapes

Doflamingo

Board Regular
Joined
Apr 16, 2019
Messages
238
Hi all,

Here is the code to add automatically connectors between 2 shapes

Code:
Set forga = Sheets("orgaShapes")
   Set f = Sheets("liensSupplémentaires")
   For Each s In forga.Shapes
    If Right(s.Name, 4) = "Lien" Then s.Delete
   Next
   Tbl = f.Range("A2:C" & f.[A65000].End(xlUp).Row).Value
   n = UBound(Tbl)
   For i = 1 To UBound(Tbl)
        shape1 = Tbl(i, 1)
        shape2 = Tbl(i, 2)
        If Tbl(i, 3) = "Arrow" Then
           forga.Shapes.AddConnector(msoConnectorStraight, 100, 100, 100, 100).Name = shape1 & shape2 & "Lien"
           forga.Shapes(shape1 & shape2 & "Lien").Line.BeginArrowheadStyle = msoArrowheadTriangle
           forga.Shapes(shape1 & shape2 & "Lien").Line.EndArrowheadStyle = msoArrowheadTriangle
        Else
           forga.Shapes.AddConnector(msoConnectorElbow, 100, 100, 100, 100).Name = shape1 & shape2 & "Lien"
           forga.Shapes(shape1 & shape2 & "Lien").Line.ForeColor.SchemeColor = 22
        End If
        forga.Shapes(shape1 & shape2 & "Lien").ConnectorFormat.BeginConnect forga.Shapes(shape1), 4
        forga.Shapes(shape1 & shape2 & "Lien").ConnectorFormat.EndConnect forga.Shapes(shape2), 2
        forga.Shapes(shape1 & shape2 & "Lien").Line.DashStyle = msoLineDash
    Next i

But with the connector arrow, for 2 different shapes, it's completely HORIZONTAL but not vertical
Code:
If Tbl(i, 3) = "Arrow" Then
           forga.Shapes.AddConnector(msoConnectorStraight, 100, 100, 100, 100).Name = shape1 & shape2 & "Lien"
           forga.Shapes(shape1 & shape2 & "Lien").Line.BeginArrowheadStyle = msoArrowheadTriangle
           forga.Shapes(shape1 & shape2 & "Lien").Line.EndArrowheadStyle = msoArrowheadTriangle
        Else

and for the connector elbow, at each creation, I have to go to ''Format'' and ''size'' for each connector if it's horizontal or vertical I have to put ''0'' to get a straight line ...

Code:
forga.Shapes.AddConnector(msoConnectorElbow, 100, 100, 100, 100).Name = shape1 & shape2 & "Lien"
           forga.Shapes(shape1 & shape2 & "Lien").Line.ForeColor.SchemeColor = 22


any idea to get elbow connector completely vertical/horizontal, same thing for vertical elbow ? :confused:
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,215,569
Messages
6,125,600
Members
449,238
Latest member
wcbyers

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top