Question: Is there any way to access Shape objects for each node inside of a SmartArt object? It seems like SmartArtNode objects have a Shapes property that could be used for this purpose, but I am getting Type mismatch errors when I try to send shapes from the SmartArtNode.Shapes to other subroutines.
Background: I am writing an iterator subroutine that takes in 2 parameters: a SmartArt object and a custom class object that has a method to perform actions on Shape objects. The subroutine is supposed to iterate over the Shape objects for each node inside the SmartArt, and call a method from the custom class object on each Shape.
Here is code for the iterator subroutine:
Public Sub IterateOverShapesInSmartArt(mySmartArt As SmartArt, manipulator As ShapeManipulator)
Dim node As SmartArtNode
Dim shpRange As ShapeRange
For Each node In mySmartArt.AllNodes
Set shpRange = node.Shapes
If shpRange.count > 0 Then
manipulator.ManipulateShape shpRange.Item(1)
End If
Next node
End Sub
For reference, the signature on the custom class (ShapeManipulator
) method being called is as follows:
Public Sub ManipulateShape(myShape As Shape)
Specific Problem: When I try running this code, I get a Run-time error '13': Type mismatch triggered by the line Set shpRange = node.Shapes
. Actually, I originally tried forgoing assignment of node.Shapes
to a temporary variable and using the method call manipulator.ManipulateShape node.Shapes(1)
instead, but then that method call produced the same Type mismatch error. I've also tried using a For
loop with counter variables instead of For Each
loop only to get the same error message. What is going on? When I debug, the Locals window shows the right types that match my declarations, so I am at a loss.