Name
shapes.AddLine(BeginX, BeginY, EndX, EndY)
Synopsis
Draws a straight line and returns the line’s Shape object.
|
Argument |
Settings |
|---|---|
|
|
The horizontal coordinate for the origin of the line |
|
|
The vertical coordinate for the origin of the line |
|
|
The horizontal coordinate for the end of the line |
|
|
The vertical coordinate for the end of the line |
Use the Line property to set the style and formatting used for the line. The following code draws a dashed line with an arrowhead:
Sub DrawLine( )
Dim ws As Worksheet, s As Shape
Set ws = ActiveSheet
' Create label (height/width will be set by AutoSize).
Set s = ws.Shapes.AddLine(100, 100, 200, 200)
s.Line.DashStyle = msoLineDash
s.Line.EndArrowheadStyle = msoArrowheadStealth
End SubBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access