CanvasShapes.AddLine (Word)

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

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

AddLine (BeginX, BeginY, EndX, EndY)


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

Arguments

The following arguments are required:

BeginX (Single) - The horizontal position, measured in points, of the line's starting point, relative to the drawing canvas.

BeginY (Single) - The vertical position, measured in points, of the line's starting point, relative to the drawing canvas.

EndX (Single) - The horizontal position, measured in points, of the line's endpoint, relative to the drawing canvas.

EndY (Single) - The vertical position, measured in points, of the line's endpoint, relative to the drawing canvas.