Share via


CanvasShapes.AddLine Method (Word)

Adds a line to a drawing canvas. Returns a Shape object that represents the line and adds it to the CanvasShapes collection.

Syntax

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

expression Required. A variable that represents a CanvasShapes collection.

Parameters

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.

Remarks

To create an arrow, use the Line property to format a line.

Example

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

See Also

Concepts

CanvasShapes Collection

CanvasShapes Object Members