向报表添加贝塞尔曲线,并返回代表曲线的 Shape 对象。
语法
              expression。 
              AddCurve
               (SafeArrayOfPoints) 
expression:一个表示 Shapes 对象的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 说明 | 
|---|---|---|---|
| SafeArrayOfPoints | 必需 | Variant | 由指定曲线的顶点和控制点的坐标对组成的数组。 | 
| SafeArrayOfPoints | 必需 | Variant | 
返回值
Shape
备注
对于 SafeArrayOfPoints 参数,您指定的第一个点是起始顶点,接下来的两个点是第一个贝塞尔段的控制点。 该曲线每增加一条线段,就要为其指定一个顶点和两个控制点。 最后指定该曲线的终点。 请注意,必须始终指定 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
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。