Share via


Shapes.AddConnector Method

Excel Developer Reference

Creates a connector. Returns a Shape 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.

Syntax

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

expression   A variable that represents a Shapes object.

Parameters

Name Required/Optional Data Type Description
Type Required MsoConnectorType The connector type to add.
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.

Return Value
Shape

Remarks

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

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.

Visual Basic for Applications
  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.<strong>AddConnector</strong> _
    Type:=msoConnectorStraight, BeginX:=150, _
    BeginY:=150, EndX:=200, EndY:=200

End Sub

See Also