Name

freeformbuilder.AddNodes(SegmentType, EditingType, X1, Y1, [X2], [Y2], [X3], [Y3])

Synopsis

Adds a segment to the freeform shape.

Argument

Settings

SegmentType

The type of segment to add. Can be msoSegmentLine or msoSegmentCurve.

EditingType

The editing property of the vertex. Can be msoEditingAuto or msoEditingCorner.

X1, X2, etc.

The horizontal coordinates of the vertices.

Y1, Y2, etc.

The vertical coordinates of the vertices.

The following code creates a freeform, adds segments, and then renders the freeform as a shape on the active worksheet:

Sub DrawAndFillFreeForm( )
    Dim ws As Worksheet, fb As FreeformBuilder, s As Shape
    Set ws = ActiveSheet
    ' Create the freeform builder.
    Set fb = ws.Shapes.BuildFreeform(msoEditingCorner, 360, 200)
    ' Add segments.
    fb.AddNodes msoSegmentCurve, msoEditingCorner, _
        380, 230, 400, 250, 450, 300
    fb.AddNodes msoSegmentCurve, msoEditingAuto, 480, 200
    fb.AddNodes msoSegmentLine, msoEditingAuto, 480, 400
    fb.AddNodes msoSegmentLine, msoEditingAuto, 360, 200
    ' Render the shape.
    Set s = fb.ConvertToShape
    ' Fill the shape.
    s.Fill.ForeColor.RGB = &HFF
    s.Fill.Solid
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.