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 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.