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:

SmartArt-1.jpg
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)
      Next
    Next
  End With
End Sub

Open in new window


But not all shapes are formatted:

SmartArt-2.jpg
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 14
Jamie GarrochPowerPoint Consultant & DeveloperAsked:
Who is Participating?
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.

Rgonzo1971Commented:
Hi,

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)
    Next
  End With

Open in new window

Regards
0

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 GarrochPowerPoint Consultant & DeveloperAuthor Commented:
Great answer thank you Rgonzo1971
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.