Link to home
Start Free TrialLog in
Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)Flag for United Kingdom of Great Britain and Northern Ireland

asked on

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":

User generated image
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?
Avatar of Rgonzo1971
Rgonzo1971

Hi,

Why do you want to keep them?

Regards
Avatar of Jamie Garroch (MVP)

ASKER

They are active icons for the user to be able to insert pictures into those shapes.
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
ASKER CERTIFIED SOLUTION
Avatar of John Wilson
John Wilson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
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.
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
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.