AddPolyline Method

AddPolyline method as it applies to the CanvasShapes object.

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.

expression.AddPolyline(SafeArrayOfPoints)

expression Required. An expression that returns a CanvasShapes object.

SafeArrayOfPoints   Required Variant. An array of coordinate pairs that specifies the polyline drawing's vertices.

AddPolyline method as it applies to the Shapes object.

Adds an open or closed polygon to a document. Returns a Shape object that represents the polygon and adds it to the Shapes collection.

expression.AddPolyline(SafeArrayOfPoints, Anchor)

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

SafeArrayOfPoints   Required Variant. An array of coordinate pairs that specifies the polyline drawing's vertices.

Anchor   Optional Variant. A Range object that represents the text to which the polyline is bound. If Anchor is specified, the anchor is positioned at the beginning of the first paragraph in the anchoring range. If this argument is omitted, the anchoring range is selected automatically and the line is positioned relative to the top and left edges of the page.

Remarks

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

Example

As it applies to the CanvasShapes object.

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

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.AddPolyline SafeArrayOfPoints:=sngArray
End Sub

As it applies to the Shapes object.

This example adds a triangle to a new document. Because the first and last points of the triangle have the same coordinates, the polygon is closed and filled.

Sub NewPolyline()
    Dim arrayTriangle(1 To 4, 1 To 2) As Single
    Dim docNew As Document

    Set docNew = Documents.Add

    'Sets the coordinates of the array
    arrayTriangle(1, 1) = 25
    arrayTriangle(1, 2) = 100
    arrayTriangle(2, 1) = 100
    arrayTriangle(2, 2) = 150
    arrayTriangle(3, 1) = 150
    arrayTriangle(3, 2) = 50
    arrayTriangle(4, 1) = 25
    arrayTriangle(4, 2) = 100

    'Adds a closed polygon to the document
    docNew.Shapes.AddPolyline SafeArrayOfPoints:=arrayTriangle
End Sub

Applies to | CanvasShapes Collection | Shapes Collection Object

See Also | AddCurve Method | AddLine Method | AddShape Method | BuildFreeform Method | ShapeNodes Collection Object