SmartArt shape fill with VBA in PowerPoint, Excel etc.

I am trying to change the format of SmartArt with VBA, more specifically, the fill colour of the AutoShapes that make up the SmartArt object.

I can successfully achieve this by looping through the GroupItems of the SmartArt object but when the item has the picture icon (it doesn't appear to be a standard placeholder object) the picture icon disappears when I set the fill colour as shown in these before and after screen captures for the 3rd SmartArt type, "Picture Caption List":

SmartArt-picture-shape-fill-color.png
Here is the simple code snippet when programming in the PowerPoint VBE:

Dim oShp as Shape
For Each oShp In ActiveWindow.Selection.ShapeRange(1).GroupItems
  If oShp.Type = msoAutoShape Then oShp.Fill.ForeColor.RGB = RGB(0, 0, 0)
Next

Open in new window


Is there a way to change the picture shape fill without losing the picture icon?
LVL 14
Jamie GarrochSenior Technical Consultant at BrightCarbonAsked:
Who is Participating?

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

x
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,

Why do you want to keep them?

Regards
0
Jamie GarrochSenior Technical Consultant at BrightCarbonAuthor Commented:
They are active icons for the user to be able to insert pictures into those shapes.
0
Rgonzo1971Commented:
HI,

If you expand the area to change the text (Type your text Here) you will see image icons if you dbl-click them you can select the image you want to insert

Regards
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

JSRWilsonCommented:
In a similar vein. "Why do you want to programatically change the colour?

In any case I think the only way to do what you want would be to access the XML (Diagram.colors1.xml file) This would be difficult to do with vba.
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 GarrochSenior Technical Consultant at BrightCarbonAuthor Commented:
JSRWilson - simple answer = because the client asked to! It's a brand police add-in.

I think I found a way round it by setting the QuickStyle property although it only allows me to change colours to the theme and not an RGB but it get what the client wants.

The items within the SmartArt object model appear to have a whole new set of properties over and above standard shapes that are not accessible via code :-(
0
JSRWilsonCommented:
Also worth knowing that the object model is totally different in 2007 from later versions. If they might use 2007 it is almost certain to fail.

Are you using groupitems to attempt to make it 2007 compliant?
0
Jamie GarrochSenior Technical Consultant at BrightCarbonAuthor Commented:
That's interesting and scary!

I'm using GroupItems as I don't need to worry about the logical  hierarchy, just the sub-shape types in order to work out how to format.
0
Jamie GarrochSenior Technical Consultant at BrightCarbonAuthor Commented:
Ah. "the object model is totally different in 2007" is usually manageable but not now I discovered this from Shyam Pillai:

"The SmartArt model is read-only in PPT 2007. So you can read information
from it by treating it as a kind of group shape but you cannot write to it."

Source : https://groups.google.com/forum/#!msg/microsoft.public.powerpoint/_jzpBnl1M0I/uqBWxcErbPkJ
0
Jamie GarrochSenior Technical Consultant at BrightCarbonAuthor Commented:
The solution to use the QuickStyle property is a partial answer in that it reset the colours but cannot be used to reset them to anything other than that defined by the presentation's theme.
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 PowerPoint

From novice to tech pro — start learning today.