|

楼主 |
发表于 2015-12-12 18:03
|
显示全部楼层
AddConnector方法
创建一个连接符。返回一个代表新连接符的Shape对象。添加一个连接符时,它没有连接到任何对象。使用BeginConnect 和EndConnect方法可将连接符的头和尾连接到文档中的其他形状上。
expression.AddConnector(Type, BeginX, BeginY, EndX, EndY)
expression 必选。该表达式返回“应用于”列表中的对象之一。
Type 必选。MsoConnectorType 类型。连接符的类型。
MsoConnectorType 可以是下列 MsoConnectorType 类型常数之一。
msoConnectorCurve
msoConnectorElbow
msoConnectorStraight
msoConnectorTypeMixed
BeginX 必选。Single 类型。连接符的起点相对于幻灯片左边缘的水平位置(以磅为单位)。
BeginY 必选。Single 类型。连接符的起点相对于幻灯片上边缘的垂直位置(以磅为单位)。
EndX 必选。Single 类型。连接符的终点相对于幻灯片左边缘的水平位置(以磅为单位)。
EndY 必选。Single 类型。连接符的终点相对于幻灯片上边缘的垂直位置(以磅为单位)。
说明
将一个连接符连接到某个形状时,如果必要,该连接符的长度和位置会自动调整。因此,如果要将一个连接符连接到其他形状,则与添加该连接符时指定的位置和长度无关。
VBA示例
本示例在 myDocument 中添加两个矩形,然后用曲线连接符将它们连接起来。请注意,将连接符连接到矩形上时,连接符的长度和位置会自动调整;因此,它与添加标注时指定的位置和长度是无关的(长度不能为零)。
Sub NewConnector()
Dim shpShapes As Shapes
Dim shpFirst As Shape
Dim shpSecond As Shape
Set shpShapes = ActivePresentation.Slides(1).Shapes
Set shpFirst = shpShapes.AddShape(Type:=msoShapeRectangle, _
Left:=100, Top:=50, Width:=200, Height:=100)
Set shpSecond = shpShapes.AddShape(Type:=msoShapeRectangle, _
Left:=300, Top:=300, Width:=200, Height:=100)
With shpShapes.AddConnector(Type:=msoConnectorCurve, BeginX:=0, _
BeginY:=0, EndX:=100, EndY:=100).ConnectorFormat
.BeginConnect ConnectedShape:=shpFirst, ConnectionSite:=1
.EndConnect ConnectedShape:=shpSecond, ConnectionSite:=1
.Parent.RerouteConnections
End With
End Sub
AddCurve方法
创建一条贝塞尔曲线。返回一个代表新曲线的Shape对象。
expression.AddCurve(SafeArrayOfPoints)
expression 必选。该表达式返回“应用于”列表中的对象之一。
SafeArrayOfPoints 必选。Variant 类型。表示一个坐标数值对数组,该数组指定曲线的顶点和控制点。指定的第一个点为起始顶点,随后的两个点为第一个贝塞尔段的控制点。然后,曲线每增加一个段,要为其指定一个顶点和两个控制点。最后指定的点为该曲线的结束顶点。请注意,必须指定 3n + 1 个点,其中 n 为曲线的段数。
VBA示例
以下示例在 myDocument 中添加一个两段的贝赛尔曲线。
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 myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddCurve SafeArrayOfPoints:=pts
AddDiagram方法
返回一个Shape对象,该对象代表添加到幻灯片、幻灯片母版或幻灯片范围中的一个图示。
expression.AddDiagram(Type, Left, Top, Width, Height)
expression 必选。该表达式返回“应用于”列表中的对象之一。
Type 必选。MsoDiagramType 类型。图示的类型。
MsoDiagramType 可以是下列 MsoDiagramType 类型常数之一。
msoDiagramCycle 显示持续循环的过程。
msoDiagramMixed 不用于此方法。
msoDiagramOrgChart 显示层次关系。
msoDiagramPyramid 显示基于基础的关系。
msoDiagramRadial 显示核心元素的关系。
msoDiagramTarget 显示实现目标的步骤。
msoDiagramVenn 显示元素间的重叠区域。
Left 必选。Single 类型。图示画布边界框左边缘相对于页面左边缘的位置(以磅为单位)。
Top 必选。Single 类型。图示画布边界框上边缘相对于页面上边缘的位置(以磅为单位)。
Width 必选。Single 类型。图示画布的边界框的宽度(以磅为单位)。
Height 必选。Single 类型。图示画布的边界框的高度(以磅为单位)。
VBA示例
以下示例将一个带四个节点的棱锥图添加到当前演示文稿的第一张幻灯片中。
Sub CreatePyramidDiagram()
Dim dgnNode As DiagramNode
Dim shpDiagram As Shape
Dim intNodes As Integer
'Adds pyramid diagram and first child node
Set shpDiagram = ActivePresentation.Slides(1).Shapes _
.AddDiagram(Type:=msoDiagramPyramid, Left:=10, _
Top:=15, Width:=400, Height:=475)
Set dgnNode = shpDiagram.DiagramNode.Children.AddNode
'Adds three more child nodes to pyramid diagram
For intNodes = 1 To 3
dgnNode.AddNode
Next intNodes
End Sub
|
|