CanvasShapes.AddConnector Method
Creates a connector. Returns a CanvasShapes object that represents the new connector. When a connector is added, it is not connected to anything. Use the BeginConnect(Shape, Int32) and EndConnect(Shape, Int32) methods to attach the beginning and end of a connector to other shapes in the document.
Namespace: Microsoft.Office.Interop.PowerPoint
Assembly: Microsoft.Office.Interop.PowerPoint (in Microsoft.Office.Interop.PowerPoint.dll)
Syntax
'Declaration
Function AddConnector ( _
Type As MsoConnectorType, _
BeginX As Single, _
BeginY As Single, _
EndX As Single, _
EndY As Single _
) As Shape
'Usage
Dim instance As CanvasShapes
Dim Type As MsoConnectorType
Dim BeginX As Single
Dim BeginY As Single
Dim EndX As Single
Dim EndY As Single
Dim returnValue As Shape
returnValue = instance.AddConnector(Type, _
BeginX, BeginY, EndX, EndY)
Shape AddConnector(
MsoConnectorType Type,
float BeginX,
float BeginY,
float EndX,
float EndY
)
Parameters
- Type
Type: Microsoft.Office.Core.MsoConnectorType
The type of connector.
- BeginX
Type: System.Single
The horizontal position, measured in points, of the connector's starting point relative to the left edge of the slide.
- BeginY
Type: System.Single
The vertical position, measured in points, of the connector's starting point relative to the top edge of the slide.
- EndX
Type: System.Single
The horizontal position, measured in points, of the connector's ending point relative to the left edge of the slide.
- EndY
Type: System.Single
The vertical position, measured in points, of the connector's ending point relative to the top edge of the slide.
Return Value
Type: Microsoft.Office.Interop.PowerPoint.Shape
Shape
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.
Examples
This example adds two rectangles to myDocument and connects them with a curved connector. Note that when you attach the connector to the rectangles, the size and position of the connector are automatically adjusted; therefore, the position and dimensions you specify when adding the callout are irrelevant (dimensions must be nonzero).
Sub NewConnector()
Dim shpShapes As Shapes
Dim shpFirst As Shape
Dim shpSecond As Shape
Set shpShapes = ActivePresentation.Slides(1).Shapes
Set shpFirst = shpShapes.AddShape(Type:=msoShapeRectangle, _
Left:=100, Top:=50, Width:=200, Height:=100)
Set shpSecond = shpShapes.AddShape(Type:=msoShapeRectangle, _
Left:=300, Top:=300, Width:=200, Height:=100)
With shpShapes.AddConnector(Type:=msoConnectorCurve, BeginX:=0, _
BeginY:=0, EndX:=100, EndY:=100).ConnectorFormat
.BeginConnect ConnectedShape:=shpFirst, ConnectionSite:=1
.EndConnect ConnectedShape:=shpSecond, ConnectionSite:=1
.Parent.RerouteConnections
End With
End Sub