Table of contents
Collapse the table of content
Expand the table of content

Shapes.AddPolyline Method (Publisher)

office 365 dev account|Last Updated: 8/24/2017
3 Contributors

Adds a new Shape object representing an open polyline or a closed polygon to the specified Shapes collection.


expression. AddPolyline( SafeArrayOfPoints)

_expression_A variable that represents a Shapes object.


NameRequired/OptionalData TypeDescription
SafeArrayOfPointsRequiredVariantAn array of coordinate pairs that specifies the polyline's or polygon's vertices.

Return Value



For the array elements in SafeArrayOfPoints, numeric values are evaluated in points; strings can be in any units supported by Microsoft Publisher (for example, "2.5 in").

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


The following example adds a triangle to the first page of the active publication. Because the first and last points have the same coordinates, the polygon is closed.

Dim shpPolyline As Shape 
Dim arrPoints(1 To 4, 1 To 2) As Single 

arrPoints(1, 1) = 25 
arrPoints(1, 2) = 100 
arrPoints(2, 1) = 100 
arrPoints(2, 2) = 150 
arrPoints(3, 1) = 150 
arrPoints(3, 2) = 50 
arrPoints(4, 1) = 25 
arrPoints(4, 2) = 100 

Set shpPolyline = ActiveDocument.Pages(1).Shapes.AddPolyline _ 
© 2018 Microsoft