ShapeNode and ShapeNodes Members
Use the ShapeNodes
collection to add or remove segments from a freeform shape. Use the Shape
object’s Nodes
property to get a reference to this collection. Use the Node
object to get the coordinates of a specific segment. The ShapeNodes
collection and ShapeNode
object have the following members:
1 Collection only | |
---|---|
2 Object and collection | |
|
|
|
|
|
|
|
|
|
|
|
|
|
It’s hard to imagine why anyone would need to modify a freeform shape from code within Excel, but if you want to do that, ShapeNodes
is the collection to use! You can modify the shape only after it is rendered from the FreeformBuilder
object by the ConvertToShape
method. The following code draws a freeform shape using an earlier example, then replaces one of the nodes in the shape:
Sub ShapeNodesMembers( ) Dim ws As Worksheet, s As Shape, sn As ShapeNodes Set ws = ActiveSheet ' Use previous example to draw freeform shape. DrawAndFillFreeForm ' Get the shape Set s = ws.Shapes(ws.Shapes.Count) ' Get the ShapeNodes Set sn = s.Nodes ' Delete a node sn.Delete (1) ' Add a node sn.Insert 1, msoSegmentCurve, msoEditingAuto, _ 20, 20, 50, 60, 30, 30 End Sub
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.