AddConnector Method

Microsoft Excel Visual Basic

object that represents the new connector. When a connector is added, it's not connected to anything. Use the BeginConnect and EndConnect methods to attach the beginning and end of a connector to other shapes in the document.

expression.AddConnector(Type, BeginX, BeginY, EndX, EndY)

expression    Required. An expression that returns one of the objects in the Applies To list.

Type   Required MsoConnectorType. The connector type to add.

MsoConnectorType can be one of these MsoConnectorType constants.
msoConnectorElbow
msoConnectorTypeMixed
msoConnectorCurve
msoConnectorStraight

BeginX    Required Single. The horizontal position (in points) of the connector's starting point relative to the upper-left corner of the document.

BeginY    Required Single. The vertical position (in points) of the connector's starting point relative to the upper-left corner of the document.

EndX    Required Single. The horizontal position (in points) of the connector's end point relative to the upper-left corner of the document.

EndY    Required Single. The veritcal position (in points) of the connector's end point relative to the upper-left corner of the document.

Remarks

When you attach a connector to a shape, the size and position of the connector are automatically adjusted, if necessary. Therefore, if you’re going to attach a connector to other shapes, the position and dimensions you specify when adding the connector are irrelevant.

Example

The following example adds a curved connector to a new canvas in a new worksheet.

Sub AddCanvasConnector()

    Dim wksNew As Worksheet
    Dim shpCanvas As Shape

    Set wksNew = Worksheets.Add

    'Add drawing canvas to new worksheet
    Set shpCanvas = wksNew.Shapes.AddCanvas( _
        Left:=150, Top:=150, Width:=200, Height:=300)

    'Add connector to the drawing canvas
    shpCanvas.CanvasItems.AddConnector _
        Type:=msoConnectorStraight, BeginX:=150, _
        BeginY:=150, EndX:=200, EndY:=200

End Sub