Upravit

Sdílet prostřednictvím


Shapes.AddPolyline method (Word)

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 object.

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.

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

See also

Shapes Collection Object

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.