PowerPoint tips, hints and tutorials that will change your presentations for ever!

INDEX

 

Jigsaws
Sounds
Video
Custom Shows
vba code
NaviSlides
Games for teachers
Bullets
Triggers
Security
Flash Cards
Multiple Instances
PowerPoint 2007
Mail Merge
Random events
Animation
Hyperlinks
Set spellcheck language


Home buttonHeaderTutorial buttonContact buttonProducts button


New Colours With vba

Now if your colours followed the color scheme or slide master you wouldn't have to do this!

Here's the scenario the client decides that the colour you have used for all the shape fills is "a little too blue". You need to change 200 shapes to a new shade! The code can also change font color where the font doesn't match the master.

This code allows you to show them the new colour, adjust it till it's correct and then swap all instances of the old colour!

To use create a shape with the NEW colour. Select it and the then ctrl click to also select a shape with the old colour. Run the code. If you are changing font colour you should still use two filled shapes as your colour samples NOT selected text.

Sub swap()
Dim lngOldcol As Long
Dim lngNewcol As Long
Dim osld As Slide
Dim oshp As Shape
Dim otxtR As TextRange
Dim i As Integer

If ActiveWindow.Selection.Type <> ppSelectionShapes Then Exit Sub
If ActiveWindow.Selection.ShapeRange.Count <> 2 Then Exit Sub

lngNewcol = ActiveWindow.Selection.ShapeRange(1).Fill.ForeColor.RGB
lngOldcol = ActiveWindow.Selection.ShapeRange(2).Fill.ForeColor.RGB

For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes

'++++++++++++++++++++++++++++++++++++++++++++++++++++
'this section changes FILL colour delete /comment out if not wanted
With oshp.Fill.ForeColor
If .RGB = lngOldcol Then _
.RGB = lngNewcol
End With
'++++++++++++++++++++++++++++++++++++++++++++++++++++

'++++++++++++++++++++++++++++++++++++++++++++++++++++
'This section changes font colour delete/comment out if not wanted
If oshp.HasTextFrame Then
If oshp.TextFrame.HasText Then
Set otxtR = oshp.TextFrame.TextRange
For i = 1 To Len(otxtR)
If otxtR.Characters(i).Font.Color.RGB = lngOldcol Then _
otxtR.Characters(i).Font.Color.RGB = lngNewcol
Next i
End If
End If
'++++++++++++++++++++++++++++++++++++++++++++++++++++

Next oshp
Next osld
End Sub

 

If you don't know how to use vba code see here

 

 
 

Back to the Index Page

POWERPOINT BLOG

Articles on your favourite sport

Free Microsoft PowerPoint Advice, help and tutorials, Template Links
This website is sponsored by Technology Trish Ltd
© Technology Trish 2007
Registered in England and Wales No.5780175
PowerPoint® is a registered trademark of the Microsoft Corporation