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 GarrochPowerPoint Consultant & DeveloperAsked:
Who is Participating?
 
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
 
Rgonzo1971Commented:
Hi,

Why do you want to keep them?

Regards
0
 
Jamie GarrochPowerPoint Consultant & DeveloperAuthor Commented:
They are active icons for the user to be able to insert pictures into those shapes.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
Jamie GarrochPowerPoint Consultant & DeveloperAuthor 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 GarrochPowerPoint Consultant & DeveloperAuthor 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 GarrochPowerPoint Consultant & DeveloperAuthor 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 GarrochPowerPoint Consultant & DeveloperAuthor 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
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.

All Courses

From novice to tech pro — start learning today.