AddLine Method

Microsoft Excel Visual Basic

object that represents the new line in a worksheet. As it applies to the CanvasShapes object, returns a Shape object that represents the new line in a drawing canvas.

expression.AddLine(BeginX, Beginy, EndX, EndY)

expression    Required. An expression that returns a Shapes object.

BeginX   , BeginY Required Single. The position (in points) of the line's starting point relative to the upper-left corner of the document.

EndX   , EndY Required Single. The position (in points) of the line's end point relative to the upper-left corner of the document.

Example

This example adds a blue dashed line to myDocument.

Set myDocument = Worksheets(1)
With myDocument.Shapes.AddLine(10, 10, 250, 250).Line
    .DashStyle = msoLineDashDotDot
    .ForeColor.RGB = RGB(50, 0, 128)
End With