VBA to format SmartArt non-node shapes in Microsoft Office PowerPoint

I am trying to programatically set the fill colour for SmartArt objects.

Some SmartArt objects work as expected but others have shapes that do not appear to be part of the AllNodes collection of the SmartArt object.

For example, if I insert the second SmartArt object type, called "Alternating Hexagons" I get this by default:

I then use the following code to change the fill colour to an arbitrary grey:

Public Sub FillSmartArt()
  Dim oShpNode As Office.Shape
  Dim oNode As SmartArtNode
  With ActiveWindow.Selection.ShapeRange(1)
    For Each oNode In .SmartArt.AllNodes
      For Each oShpNode In oNode.Shapes
         oShpNode.Fill.ForeColor.RGB = RGB(128,128,128)
  End With
End Sub

Open in new window

But not all shapes are formatted:

Does the object model support the additional shapes that do not appear to be part of the AllNodes collection?

One side comment, when I use .SmartArt.AllNodes.Count, I get 9 but after further investigation, this SmartArt object is returning two shapes for each child, neither of which is the shape that remains filled with blue.
LVL 15
Jamie GarrochSenior Technical Consultant at BrightCarbonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Since the other shapes are not nodes, pls try this

  With ActiveWindow.Selection.ShapeRange(1)
    For Each oGrpItems In .GroupItems
        oGrpItems.Fill.ForeColor.RGB = RGB(128, 128, 128)
  End With

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jamie GarrochSenior Technical Consultant at BrightCarbonAuthor Commented:
Great answer thank you Rgonzo1971
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.