共用方式為


Shapes.AddLine 方法 (專案)

在報告中新增一條線,並回傳一個代表該行的 Shape 物件。

語法

expressionAddLine (開始X,開始Y,結束X,結束Y)

expression 代表 Shapes 物件的變數。

參數

名稱 必要/選用 資料類型 描述
開始X 必要 Single 水平位置 (起點相對於報告左邊) 點。
開始 必要 Single 垂直位置 (起點相對於報告頂端) 點。
終結 必要 Single 水平位置 (在相對於報告左側邊緣的終點) 點。
結束 必要 Single 垂直位置 (相對於報告頂端) 點。
開始X 必要
開始 必要
終結 必要
結束 必要
名稱 必要/選用 資料類型 描述

傳回值

圖形

註解

若要格式化線條,請使用 Shape.Line 屬性。

範例

以下範例會產生一條紫色虛無線,末端有箭頭。

Sub AddBigArrow()
    Dim shapeReport As Report
    Dim reportName As String
    Dim lineShape As shape
    
    ' Add a report.
    reportName = "Line report"
    Set shapeReport = ActiveProject.Reports.Add(reportName)

    Set lineShape = shapeReport.Shapes.AddLine(20, 50, 320, 100)
    
    With lineShape.Line
        .DashStyle = msoLineDashDot
        .Weight = 3
        .EndArrowheadStyle = msoArrowheadTriangle
        .EndArrowheadWidth = msoArrowheadWidthMedium
        .ForeColor.RGB = &HFF0090
    End With
End Sub

另請參閱

形狀 物件形狀 物件行屬性

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應