Class ShapeNodes (PowerPoint VBA)

A collection of all the ShapeNode objects in the specified freeform. To use a ShapeNodes class variable it first needs to be instantiated, for example


Dim sns as ShapeNodes
Set sns = ActiveWindow.RangeFromPoint.Nodes

Count

Returns the number of objects in the specified collection.


Dim lngCount As Long
lngCount = ActiveWindow.RangeFromPoint.Nodes.Count

Delete

Deletes a shape node.

The segment following the Index node is also deleted. If the node is a control point of a curve, the curve and all of its nodes are deleted.

Delete (Index)

Index: Specifies the node to be deleted.


Dim lngIndex As Long: lngIndex = 
ActiveWindow.RangeFromPoint.Nodes.Delete Index:=lngIndex

Insert

Inserts a new segment after the specified node of the freeform.

The SegmentType parameter value can be one of these MsoSegmentType constants.

Insert (Index, SegmentType, EditingType, X1, Y1, X2, Y2, X3, Y3)


Dim lngIndex As Long: lngIndex = 
ActivePresentation.Slides(1).Shapes(1).Nodes.Insert Index:=lngIndex, SegmentType:=msoSegmentLine, EditingType:=msoEditingAuto, X1:=210, Y1:=100

Arguments

The following arguments are required:

Index (Long) - The node that the new node is to be inserted after.

SegmentType (Office.MsoSegmentType) - The type of segment to be added.

EditingType (Office.MsoEditingType) - The editing property of the vertex.

X1 (Single) - If the EditingType of the new segment is msoEditingAuto, this argument specifies the horizontal distance (in points) from the upper-left corner of the document to the endpoint of the new segment. If the EditingType of the new node is msoEditingCorner, this argument specifies the horizontal distance (in points) from the upper-left corner of the document to the first control point for the new segment.

Y1 (Single) - If the EditingType of the new segment is msoEditingAuto, this argument specifies the vertical distance (in points) from the upper-left corner of the document to the endpoint of the new segment. If the EditingType of the new node is msoEditingCorner, this argument specifies the vertical distance (in points) from the upper-left corner of the document to the first control point for the new segment.

Optional arguments

The following arguments are optional

X2 (Single) - If the EditingType of the new segment is msoEditingCorner, this argument specifies the horizontal distance (in points) from the upper-left corner of the document to the second control point for the new segment. If the EditingType of the new segment is msoEditingAuto, don't specify a value for this argument.

Y2 (Single) - If the EditingType of the new segment is msoEditingCorner, this argument specifies the vertical distance (in points) from the upper-left corner of the document to the second control point for the new segment. If the EditingType of the new segment is msoEditingAuto, don't specify a value for this argument.

X3 (Single) - If the EditingType of the new segment is msoEditingCorner, this argument specifies the horizontal distance (in points) from the upper-left corner of the document to the endpoint of the new segment. If the EditingType of the new segment is msoEditingAuto, don't specify a value for this argument.

Y3 (Single) - If the EditingType of the new segment is msoEditingCorner, this argument specifies the vertical distance (in points) from the upper-left corner of the document to the endpoint of the new segment. If the EditingType of the new segment is msoEditingAuto, don't specify a value for this argument.

Item

Returns a single ShapeNode object from the specified ShapeNodes collection.

Item (Index)

Index: The name or index number of the single ShapeNode object in the collection to be returned.


Dim shpn As ShapeNode
Set shpn = ActiveWindow.RangeFromPoint.Nodes(Index:=1)

SetEditingType

Sets the editing type of the specified node.

If the node specified by Index is a control point for a curved segment, this method sets the editing type of the node adjacent to it that joins two segments. Note that, depending on the editing type, this method may affect the position of adjacent nodes. The EditingType parameter value can be one of these MsoEditingType constants.

SetEditingType (Index, EditingType)


With ActivePresentation.Slides(1).Shapes(3).Nodes
    For n = 1 to .Count
        If .Item(n).EditingType = msoEditingCorner Then
            .SetEditingType n, msoEditingSmooth
        End If
    Next
End With

Arguments

The following arguments are required:

Index (Long) - The node whose editing type is to be set.

EditingType (Office.MsoEditingType) - The editing type.

SetPosition

Sets the location of the node specified by Index. Note that, depending on the editing type of the node, this method may affect the position of adjacent nodes.

SetPosition (Index, X1, Y1)


With ActivePresentation.Slides(1).Shapes(3).Nodes
    pointsArray = .Item(2).Points
    currXvalue = pointsArray(1, 1)
    currYvalue = pointsArray(1, 2)
    .SetPosition 2, currXvalue + 200, currYvalue + 300
End With

Arguments

The following arguments are required:

Index (Long) - The node whose position is to be set.

X1 (Single) - The x-position (in points) of the new node relative to the upper-left corner of the document.

Y1 (Single) - The y-position (in points) of the new node relative to the upper-left corner of the document.

SetSegmentType

Sets the segment type of the segment that follows the specified node.

If the node specified by Index is a control point for a curved segment, this method sets the segment type for that curve. Note that this may affect the total number of nodes by inserting or deleting adjacent nodes. The SegmentType parameter value can be one of these MsoSegmentType constants.

SetSegmentType (Index, SegmentType)


With ActivePresentation.Slides(1).Shapes(3).Nodes
    n = 1
    While n <= .Count
        If .Item(n).SegmentType = msoSegmentLine Then
            .SetSegmentType n, msoSegmentCurve
        End If
        n = n + 1
    Wend
End With

Arguments

The following arguments are required:

Index (Long) - The node whose segment type is to be set.

SegmentType (Office.MsoSegmentType) - Specifies if the segment is straight or curved.