Name

shapes.AddCurve(SafeArrayOfPoints)

Synopsis

Draws a Bézier curve from an array of coordinate pairs and returns the curve’s Shape object.

Argument

Settings

SafeArrayOfPoints

The 2-D array of points containing the vertices and control points of the curve

The following code draws an S-shaped curve that starts at (80,100) and ends at (110,30):

Sub DrawCurve( )
    Dim s As Shape, pts( ) As Single
    ' Array of points.
    ReDim pts(3, 1)
    pts(0, 0) = 80
    pts(0, 1) = 100
    pts(1, 0) = 200
    pts(1, 1) = 150
    pts(2, 0) = 15
    pts(2, 1) = 20
    pts(3, 0) = 110
    pts(3, 1) = 30
    ' Draw a curve
    Set s = ActiveSheet.Shapes.AddCurve(pts)
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.