在图表内移动图表节点及其任意一个子节点。
expression.MoveNode(pTargetNode, pos)
expression 必需。该表达式返回“应用于”列表中的对象之一。
pTargetNode DiagramNode 对象,必需。图表节点,指定节点要移动到该图表节点的位置上。
pos MsoRelativeNodePosition 类型,必需。相对于 TargetNode,要移动节点的位置。
MsoRelativeNodePosition 可为以下 MsoRelativeNodePosition 常量之一: |
msoAfterLastSibling |
msoAfterNode |
msoBeforeFirstSibling |
msoBeforeNode |
下例将新建图表的第二个图表节点移到最后一个节点处。
Sub MoveDiagramNode()
Dim dgnNode As DiagramNode
Dim shpDiagram As Shape
Dim intCount As Integer
'Add pyramid diagram to the current document
Set shpDiagram = ActiveSheet.Shapes.AddDiagram( _
Type:=msoDiagramPyramid, Left:=10, _
Top:=15, Width:=400, Height:=475)
'Add four child nodes to the pyramid diagram
Set dgnNode = shpDiagram.DiagramNode.Children.AddNode
For intCount = 1 To 3
dgnNode.AddNode
Next intCount
'Move the second node to after where the
'fourth node is currently located.
dgnNode.Diagram.Nodes(2).MoveNode _
pTargetNode:=dgnNode.Diagram.Nodes(4), _
Pos:=msoAfterLastSibling
End Sub