title | keywords | f1_keywords | api_name | ms.assetid | ms.date | ms.localizationpriority | ||
---|---|---|---|---|---|---|---|---|
Shapes.AddLine method (Word) |
vbawd10.chm161415182 |
|
|
d1c609c3-d5d1-80e8-4f95-184a9a536feb |
06/08/2017 |
medium |
Adds a line to a drawing canvas.
expression.AddLine (BeginX, BeginY, EndX, EndY)
expression Required. A variable that represents a Shapes object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
BeginX | Required | Single | The horizontal position, measured in points, of the line's starting point, relative to the drawing canvas. |
BeginY | Required | Single | The vertical position, measured in points, of the line's starting point, relative to the drawing canvas. |
EndX | Required | Single | The horizontal position, measured in points, of the line's endpoint, relative to the drawing canvas. |
EndY | Required | Single | The vertical position, measured in points, of the line's endpoint, relative to the drawing canvas. |
To create an arrow, use the Line property to format a line.
This example adds a purple line with an arrow to a new drawing canvas.
Sub NewCanvasLine()
Dim shpCanvas As Shape
Dim shpLine As Shape
'Add new drawing canvas to the active document
Set shpCanvas = ActiveDocument.Shapes _
.AddCanvas(Left:=100, Top:=75, _
Width:=150, Height:=200)
'Add a line to the drawing canvas
Set shpLine = shpCanvas.CanvasItems.AddLine( _
BeginX:=25, BeginY:=25, EndX:=150, EndY:=150)
'Add an arrow to the line and sets the color to purple
With shpLine.Line
.BeginArrowheadStyle = msoArrowheadDiamond
.BeginArrowheadWidth = msoArrowheadWide
.ForeColor.RGB = RGB(Red:=150, Green:=0, Blue:=255)
End With
End Sub
[!includeSupport and feedback]