Shapes.AddPolyline Method

Word Developer Reference

Adds an open or closed polygon to a drawing canvas. Returns a Shape object that represents the polygon and adds it to the CanvasShapes collection.

Syntax

expression.AddPolyline(SafeArrayOfPoints)

expression   Required. A variable that represents a Shapes collection.

Parameters

Name Required/Optional Data Type Description
SafeArrayOfPoints Required Variant An array of coordinate pairs that specifies the polyline drawing's vertices.

Remarks

To form a closed polygon, assign the same coordinates to the first and last vertices in the polyline drawing.

Example

This example creates a V-shaped open polyline in a new drawing canvas.

Visual Basic for Applications
  Sub NewCanvasPolyline()
    Dim docNew As Document
    Dim shpCanvas As Shape
    Dim sngArray(1 To 3, 1 To 2) As Single
'Creates a new document and adds a drawing canvas
Set docNew = Documents.Add
Set shpCanvas = docNew.Shapes.AddCanvas( _
    Left:=100, Top:=75, Width:=200, Height:=300)

'Sets the coordinates of the array
sngArray(1, 1) = 100
sngArray(1, 2) = 75
sngArray(2, 1) = 150
sngArray(2, 2) = 100
sngArray(3, 1) = 100
sngArray(3, 2) = 125

'Adds a V-shaped open polyline to the drawing canvas
shpCanvas.CanvasItems.<strong class="bterm">AddPolyline</strong> SafeArrayOfPoints:=sngArray

End Sub

See Also