Skip to content

Latest commit

 

History

History
63 lines (40 loc) · 1.56 KB

Excel.Shapes.AddPolyline.md

File metadata and controls

63 lines (40 loc) · 1.56 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Shapes.AddPolyline method (Excel)
vbaxl10.chm638083
vbaxl10.chm638083
Excel.Shapes.AddPolyline
b9caacf9-c87c-224e-c948-a96aceb3a0ee
05/15/2019
medium

Shapes.AddPolyline method (Excel)

Creates an open polyline or a closed polygon drawing. 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 polyline drawing's vertices.

Return value

Shape

Remarks

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

Example

This example adds a triangle to myDocument. Because the first and last points have the same coordinates, the polygon is closed and filled. The color of the triangle's interior will be the same as the default shape's fill color.

Dim triArray(1 To 4, 1 To 2) As Single 
triArray(1, 1) = 25 
triArray(1, 2) = 100 
triArray(2, 1) = 100 
triArray(2, 2) = 150 
triArray(3, 1) = 150 
triArray(3, 2) = 50 
triArray(4, 1) = 25 ' Last point has same coordinates as first 
triArray(4, 2) = 100 
Set myDocument = Worksheets(1) 
myDocument.Shapes.AddPolyline triArray

[!includeSupport and feedback]