AddCurve Method

Microsoft Word Visual Basic

Show All

AddCurve Method

       

AddCurve method as it applies to the CanvasShapes object.

Returns a Shape object that represents a Bézier curve in a drawing canvas.

expression.AddCurve(SafeArrayOfPoints)

expression   Required. An expression that returns a CanvasShapes object..

SafeArrayOfPoints  Required Variant. An array of coordinate pairs that specifies the vertices and control points of the curve. The first point you specify is the starting vertex, and the next two points are control points for the first Bézier segment. Then, for each additional segment of the curve, you specify a vertex and two control points. The last point you specify is the ending vertex for the curve. Note that you must always specify 3n + 1 points, where n is the number of segments in the curve.

AddCurve method as it applies to the Shapes object.

Returns a Shape object that represents a Bézier curve in a document.

expression.AddCurve(SafeArrayOfPoints, Anchor)

expression   Required. An expression that returns a Shapes object.

SafeArrayOfPoints  Required Variant. An array of coordinate pairs that specifies the vertices and control points of the curve. The first point you specify is the starting vertex, and the next two points are control points for the first Bézier segment. Then, for each additional segment of the curve, you specify a vertex and two control points. The last point you specify is the ending vertex for the curve. Note that you must always specify 3n + 1 points, where n is the number of segments in the curve.

Anchor  Optional Variant. A Range object that represents the text to which the curve is bound. If Anchor is specified, the anchor is positioned at the beginning of the first paragraph in the anchoring range. If this argument is omitted, the anchoring range is selected automatically and the curve is positioned relative to the top and left edges of the page.

Example

As it applies to the CanvasShapes object.

This example adds a Bézier curve to a new drawing canvas.

Sub CanvasBezier()

    Dim docNew As Document
    Dim shpCanvas As Shape
    Dim sngArray(1 To 7, 1 To 2) As Single

    Set docNew = Documents.Add

    'Create a new drawing canvas
    Set shpCanvas = docNew.Shapes.AddCanvas(Left:=100, _
        Top:=100, Width:=300, Height:=50)

    sngArray(1, 1) = 0
    sngArray(1, 2) = 0
    sngArray(2, 1) = 50
    sngArray(2, 2) = 50
    sngArray(3, 1) = 100
    sngArray(3, 2) = 0
    sngArray(4, 1) = 150
    sngArray(4, 2) = 50
    sngArray(5, 1) = 200
    sngArray(5, 2) = 0
    sngArray(6, 1) = 250
    sngArray(6, 2) = 50
    sngArray(7, 1) = 300
    sngArray(7, 2) = 0

    'Add Bezier curve to drawing canvas
    shpCanvas.CanvasItems.AddCurve _
        SafeArrayOfPoints:=sngArray

End Sub

As it applies to the Shapes object.

This example adds a two-segment Bézier curve to the active document and anchors it to the second paragraph.

Sub BezierCurve()
    Dim sngArray(1 To 7, 1 To 2) As Single

    sngArray(1, 1) = 0
    sngArray(1, 2) = 0
    sngArray(2, 1) = 72
    sngArray(2, 2) = 72
    sngArray(3, 1) = 100
    sngArray(3, 2) = 40
    sngArray(4, 1) = 20
    sngArray(4, 2) = 50
    sngArray(5, 1) = 90
    sngArray(5, 2) = 120
    sngArray(6, 1) = 60
    sngArray(6, 2) = 30
    sngArray(7, 1) = 150
    sngArray(7, 2) = 90

    ActiveDocument.Shapes.AddCurve _
        SafeArrayOfPoints:=sngArray, _
        Anchor:=ActiveDocument.Paragraphs(2).Range
End Sub