Shapes.AddPolyline method (Project)
Creates an open polyline or a closed polygon drawing, and returns a Shape object that represents the new polyline or polygon.
Syntax
expression. AddPolyline
(SafeArrayOfPoints)
expression A variable that represents a Shapes object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
SafeArrayOfPoints | Required | Variant | An array of coordinate pairs that specifies the vertices of the polyline. |
SafeArrayOfPoints | Required | Variant | |
Name | Required/Optional | Data type | Description |
Return value
Shape
Remarks
To form a closed polygon, assign the same coordinates to the first and last vertices in the polyline drawing. For a closed polygon, the default shape fill color is a medium blue: &HD59B5B, or RGB(Red:=91, Green:=155, Blue:=213)
.
Example
Because the first and last points are the same, the following example creates a closed octagon. The violet line is two points wide; the octagon is filled with a gold color.
Sub AddOctagon()
Dim shapeReport As Report
Dim reportName As String
Dim polylineShape As shape
' Add a report.
reportName = "Polyline report"
Set shapeReport = ActiveProject.Reports.Add(reportName)
Dim octArray(1 To 9, 1 To 2) As Single
octArray(1, 1) = 9
octArray(1, 2) = 8
octArray(2, 1) = 19
octArray(2, 2) = 8
octArray(3, 1) = 26
octArray(3, 2) = 15
octArray(4, 1) = 26
octArray(4, 2) = 25
octArray(5, 1) = 19
octArray(5, 2) = 32
octArray(6, 1) = 9
octArray(6, 2) = 32
octArray(7, 1) = 2
octArray(7, 2) = 25
octArray(8, 1) = 2
octArray(8, 2) = 15
octArray(9, 1) = 9
octArray(9, 2) = 8
Set polylineShape = shapeReport.Shapes.AddPolyline(octArray)
With polylineShape.Line
.Weight = 2
.ForeColor.RGB = &HFF0090 ' Violet color.
End With
polylineShape.Fill.ForeColor.RGB = &H10D0D0 ' Gold color.
End Sub
See also
Shapes Object Shape Object Line Property Fill Property
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.