Class ShapeNode (Word VBA)

The class ShapeNode represents the geometry and the geometry-editing properties of the nodes in a user-defined freeform. Nodes include the vertices between the segments of the freeform and the control points for curved segments. The ShapeNode object is a member of the ShapeNodes collection. The ShapeNodes collection contains all the nodes in a freeform. To use a ShapeNode class variable it first needs to be instantiated, for example

For Each

Here is an example of processing the ShapeNode items in a collection.


Dim shp As Shape: Set shp = 
Dim shpnNode As ShapeNode
For Each shpnNode In shp.Nodes
	With shpnNode
		
	End With
Next shpnNode

EditingType

If the specified node is a vertex, this property returns a value that indicates how changes made to the node affect the two segments connected to the node. Read-only MsoEditingType.

If the node is a control point for a curved segment, this property returns the editing type of the adjacent vertex. This property is read-only. Use the SetEditingType method to set the value of this property.


Dim docActive As Document 
Dim intCount As Integer 
 
Set docActive = ActiveDocument 
 
With docActive.Shapes(3).Nodes 
 For intCount = 1 to .Count 
 If .Item(intCount).EditingType = msoEditingCorner Then 
 .SetEditingType intCount, msoEditingSmooth 
 End If 
 Next 
End With

Points

Returns the position of the specified node as a coordinate pair. Read-only Variant.

Each coordinate is expressed in points. Use the SetPosition method to set the location of the node.


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

SegmentType

Returns a value that indicates whether the segment associated with the specified node is straight or curved.

If the specified node is a control point for a curved segment, this property returns msoSegmentCurve. Use the SetSegmentType method to set the value of this property.


Set myDocument = ActiveDocument 
With myDocument.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