go through all objects in a presentation with a vba-script

D

Dominik Spies

Hallo Group,

I need to write a macro for Powerpoint2003, that should perform this
action:

look if the first object can have a color. If yes, check if object has
a SchemeColor. If yes, get the 'absolute' color of this SchemeColor and
set the color of the object to this color.
proceed with next object.

I need this because when you use templates with SchemeColors and
someone defines e.g. a text with a SchemeColor and you copy this text
to another presentation the text maybe have another color.
So the macro should be performed before you copy something and then all
color are defined 'absolute'.

The changinf of the color is not a problem, but how I can go through
all objects of a presentation? textboxes, lines, borders, arrows, and
so on..

I looked at msdn bit didn't find a solution.

Thanks for any help
 
D

David M. Marcovitz

Well, you can start with something like:

For Each sld in ActivePresentation.Slides
For Each shp in sld.Shapes
....
Next shp
Next sld

You might have to do something special with grouped objects as well, and
I just typed this off the top of my head so there might be errors, but
this should get you started.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
S

Steve Rindsberg

look if the first object can have a color. If yes, check if object has
a SchemeColor. If yes, get the 'absolute' color of this SchemeColor and
set the color of the object to this color.
proceed with next object.


This will get you started:

Sub StopScheming()

Dim oSh As Shape
Dim oSl As Slide

For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
oSh.Fill.ForeColor.RGB = oSh.Fill.ForeColor.RGB
Next
Next

End Sub

Left as an exercise for the reader (transl: LOTS more work for you! <g>)

- Line color
- Background color (eg. if it's a patterned fill)
- Groups
- Slide masters/designs if needed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top