|
请参考: 应用于 Shapes 对象的 AddCurve 方法。返回一个 Shape 对象,该对象代表文档中的贝赛尔曲线。expression.AddCurve(SafeArrayOfPoints, Anchor)expression 必需。该表达式返回一个 Shapes 对象。SafeArrayOfPoints Variant 类型,必需。指定该曲线的顶点和控制点的坐标对数组。首先指定的是起始顶点,随后指定的两个点是第一段贝塞尔曲线的控制点。如果该曲线还有其他段,则每段都应该指定一个顶点和两个控制点。最后指定该曲线的终止顶点。请注意,一般情况下您应该指定 3n + 1 个点,此处 n 为曲线的段数。Anchor Variant 类型,可选。指定一个代表文本的 Range 对象,该曲线将出现在此文本中。如果指定了 Anchor,则锁定标记位于锁定区域中第一段的段首。如果忽略此参数,将自动选定锁定区域,而标签将相对于页面的上边缘和左边缘进行定位。示例当应用于 CanvasShapes 对象时。本示例在新画布上添加一条贝赛尔曲线。Sub CanvasBezier() Dim docNew As Document Dim shpCanvas As Shape Dim sngArray(1 To 7, 1 To 2) As Single Set docNew = Documents.Add 'Create a new drawing canvas Set shpCanvas = docNew.Shapes.AddCanvas(Left:=100, _ Top:=100, Width:=300, Height:=50) sngArray(1, 1) = 0 sngArray(1, 2) = 0 sngArray(2, 1) = 50 sngArray(2, 2) = 50 sngArray(3, 1) = 100 sngArray(3, 2) = 0 sngArray(4, 1) = 150 sngArray(4, 2) = 50 sngArray(5, 1) = 200 sngArray(5, 2) = 0 sngArray(6, 1) = 250 sngArray(6, 2) = 50 sngArray(7, 1) = 300 sngArray(7, 2) = 0 'Add Bezier curve to drawing canvas shpCanvas.CanvasItems.AddCurve _ SafeArrayOfPoints:=sngArrayEnd Sub当应用于 Shapes 对象时。本示例向活动文档添加一条两段的贝塞尔曲线,并且将其定位在第一段。Sub BezierCurve() Dim sngArray(1 To 7, 1 To 2) As Single sngArray(1, 1) = 0 sngArray(1, 2) = 0 sngArray(2, 1) = 72 sngArray(2, 2) = 72 sngArray(3, 1) = 100 sngArray(3, 2) = 40 sngArray(4, 1) = 20 sngArray(4, 2) = 50 sngArray(5, 1) = 90 sngArray(5, 2) = 120 sngArray(6, 1) = 60 sngArray(6, 2) = 30 sngArray(7, 1) = 150 sngArray(7, 2) = 90 ActiveDocument.Shapes.AddCurve _ SafeArrayOfPoints:=sngArray, _ Anchor:=ActiveDocument.Paragraphs(1).RangeEnd Sub |
|