Word) (Shapes.AddLine 方法
將線條新增至繪圖畫布中。
語法
運算式。AddLine (BeginX、 BeginY、 EndX、 EndY)
需要 expression。 代表 Shapes 物件的 變數。
參數
名稱 | 必要/選用 | 資料類型 | 描述 |
---|---|---|---|
BeginX | 必要 | Single | 相對於繪圖畫布之線條起點的水平位置 (以點為測量單位) |
BeginY | 必要 | Single | 相對於繪圖畫布之線條起點的垂直位置 (以點為測量單位) |
EndX | 必要 | Single | 相對於繪圖畫布之線條終點的水平位置 (以點為測量單位) |
EndY | 必要 | Single | 相對於繪圖畫布之線條終點的垂直位置 (以點為測量單位) |
傳回值
註解
若要建立箭號,請使用 Line 屬性來繪製線條。
範例
本範例會將含有箭頭的紫色線條加入新的繪圖畫布中。
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
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。