共用方式為


Shapes.AddCurve 方法 (Project)

將貝塞爾曲線加入至報表,並傳回代表曲線的 Shape 物件。

語法

expressionAddCurve (SafeArrayOfPoints)

expression 代表 Shapes 物件的變數。

參數

名稱 必要/選用 資料類型 描述
SafeArrayOfPoints 必要 Variant 用於指定區線上之頂點和控制點的座標組陣列。
SafeArrayOfPoints 必要 Variant

傳回值

圖形

註解

對於 SafeArrayOfPoints 參數,您指定的第一個點是起始頂點,而接下來的兩個點是第一個 Bézier 區段的控制點。 然後,對於曲線的每個貝塞爾段落,指定一個頂點和兩個控制點。 所指定的最後一個點應是曲線的終止頂點。 請注意,您必須一律指定 3 n + 1 點,其中 n 是曲線中的線段數目。

範例

下列範例會建立具有七個頂點的曲線,從報表的左上角開始。 曲線會設定為兩點寬的黃色-綠色線條。

Sub AddBezierCurve()
    Dim shapeReport As Report
    Dim reportName As String
    Dim curveShape As shape
    
    ' Add a report.
    reportName = "Curve report"
    Set shapeReport = ActiveProject.Reports.Add(reportName)

    Dim pts(1 To 7, 1 To 2) As Single
    pts(1, 1) = 0
    pts(1, 2) = 0
    pts(2, 1) = 72
    pts(2, 2) = 72
    pts(3, 1) = 100
    pts(3, 2) = 40
    pts(4, 1) = 20
    pts(4, 2) = 50
    pts(5, 1) = 90
    pts(5, 2) = 120
    pts(6, 1) = 60
    pts(6, 2) = 30
    pts(7, 1) = 150
    pts(7, 2) = 90

    Set curveShape = shapeReport.Shapes.AddCurve(pts)

    With curveShape
        .Line.Weight = 2
        .Line.ForeColor.RGB = &H1FFAA
    End With
End Sub

另請參閱

Shapes 物件Shape 物件Line 屬性

支援和意見反應

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