We help IT Professionals succeed at work.

Change color

656 Views
Last Modified: 2012-08-14
Is there a feature in PowerPoint 2010 that allows the user to automatically change one color to another?
For example, I want all green text on my slide to become blue.

If yes, please give me a step by step procedure.

Thanks!
Comment
Watch Question

John WilsonCEO PowerPoint Alchemy
CERTIFIED EXPERT

Commented:
If your slides follow the master slide you can change the color there. If not using code is the only answer. Is the green the exact same green everywhere?

Author

Commented:
It is the same everywhere. It does not follow the master slide. I changed colors manually.
Top Expert 2011

Commented:
You can update the Master Slide to get the font color schemes how you need it, then Close Slide Master. To apply this Master Slide font scheme to all the existing slides, select all of the slides (whether from the Slide Sorter view or from the left-side navigation pane), go to the Home tab, click the Reset button under the Slides section. This will, in one fell swoop, update all of the slides to be in accordance with what the Slide Master has set.
Top Expert 2011

Commented:
So that means updating the Slide Master with green font text (even if the fonts already in the Slide Master are not even blue) and then run the Reset I noted above.
Top Expert 2011

Commented:
^ I meant to note to change all the green font text to blue, not blue to green.... >_<

I tested this earlier with manually (different and various) set font colors for each of five different slides and I got them all to turn into blue font text after running the process I noted originally.

Author

Commented:
@yobri: I'm a little confused. Could you give me a step  by step procedure.
I have a single slide and I just want to transform all words with color A to color B.

Thanks!
Top Expert 2011

Commented:
Go to View tab > Slide Master button.

Edit each text box on each slide here in the Slide Master with font color blue. Click into a text box, select all the text with your mouse, right-click and click on Font. Change the Font color paint bucket dropdown button and choose one of the blue colors (that you prefer). Do this for each text box in the Slide Master slides.

Once each slide has blue text in each, click the Close Master View button in the ribbon (under the Slide Master tab).

Go to the Home tab. In the Slides section, click the Reset button. All the text (in textboxes) in the file should turn blue accordingly.

Author

Commented:
Well, I don't want all the text to turn into blue. I wont only those few words in green to turn blue.
All my text is in color A, expect for a few words here and there in color B. I want those words (B) to turn to color C.
Top Expert 2011

Commented:
If the green font is in the same places on each slide for which it appears, then you can only update the text boxes (to blue) in the Slide Master that you know would contain the green text...

The only other way to perform this selective green to blue for various text boxes in the document would employ a VBA attempt at a solution since the Find and Replace functions in Powerpoint are rather shallow...

Author

Commented:
Would it be possible to do it with VBA?
Top Expert 2011

Commented:
I'll try to explore this tomorrow... that is, if no one else does so before then.
CERTIFIED EXPERT
Top Expert 2011

Commented:
Try the following code which cycles around every slide and every shape and if the shape is either an autoshape or a textbox it checks each character for the color change.  It may need tweaking as it is likely that the selection is too broad but try it ON A COPY of your file and let me know the errors / Omissions

You will need to know the color values for the from and to code but assuming for example they are vbred and vbgreen then call as

changetext vbred, vbgreen

to change red text to green text

Chris
Sub changeText(lngOldColor As Long, lngNewColor As Long)
Dim shp As Shape
Dim sld As Slide
Dim cnt As Long

    For Each sld In ActivePresentation.Slides
        For Each shp In sld.Shapes
            If shp.Type = msoTextBox Or shp.Type = msoPlaceholder Then
                For cnt = 1 To Len(shp.TextFrame.TextRange.Text)
                    If shp.TextFrame.TextRange.Characters(cnt, 1).Font.Color = lngOldColor Then
                        shp.TextFrame.TextRange.Characters(cnt, 1).Font.Color = lngNewColor
                    End If
                Next
            'ElseIf shp.Type = msoPlaceholder Then
            End If
        Next
    Next
End Sub

Open in new window

Author

Commented:
Do I enter it in Hex?
If the Hex code of the color is "0000B4", then do I just replace "lngOldColor" with "0000B4"?

Author

Commented:
How do I view the changes made by the macro? Will it happen automatically, as soon as I save it?
CERTIFIED EXPERT
Top Expert 2011

Commented:
Noting your other question referred to tables, perhaps you have text in tables to process as well so the following adds tables to the process:


Chris
Sub changeText(lngOldColor As Long, lngNewColor As Long)
Dim shp As Shape
Dim sld As Slide
Dim cnt As Long
Dim rw As Integer
Dim col As Integer

    For Each sld In ActivePresentation.Slides
        For Each shp In sld.Shapes
            If shp.Type = msoTextBox Or shp.Type = msoPlaceholder Then
                For cnt = 1 To Len(shp.TextFrame.TextRange.Text)
                    If shp.TextFrame.TextRange.Characters(cnt, 1).Font.Color = lngOldColor Then
                        shp.TextFrame.TextRange.Characters(cnt, 1).Font.Color = lngNewColor
                    End If
                Next
            ElseIf shp.HasTable Then
                For rw = 1 To shp.Table.Rows.Count
                    For col = 1 To shp.Table.Columns.Count
                        With shp.Table.Cell(rw, col).Shape.TextFrame.TextRange
                            For cnt = 1 To Len(.Text)
                                If .Characters(cnt, 1).Font.Color = lngOldColor Then
                                    .Characters(cnt, 1).Font.Color = lngNewColor
                                End If
                            Next
                        End With
                    Next
                Next
            End If
        Next
    Next
End Sub

Open in new window

Author

Commented:
Well, the text is in a Text Box
Could you tell me how the hex color code must be represented, and when I can expect to see  the changes? Does the macro run automatically?
CERTIFIED EXPERT
Top Expert 2011

Commented:
You have to run the macro for the changes to take effect.  Add the following macro to force a specific change from your hex value to green ... the parameters prevent running via the dialog.  Similarly replace vbgreen with a hex conversion as below:

val("&hABCDEF")

The hex value referred is entered as the long equivalent via the val function as below.

Chris

sub testChangeText
    changetext val("&h0000B4"), vbgreen
end sub

Open in new window

CERTIFIED EXPERT
Top Expert 2011

Commented:
To run a macro ... having inserted it into a code module press alt + F8 from powerpoint and find the testChangeText, (or whatever you called it) sub and selelect it then click run.

Chris

Author

Commented:
This is how my code looks like:

When I click F5, I get Run-time error. The specified value is ou of range.
Sub changeText(lngOldColor As Long, lngNewColor As Long)
Dim shp As Shape
Dim sld As Slide
Dim cnt As Long

    For Each sld In ActivePresentation.Slides
        For Each shp In sld.Shapes
            If shp.Type = msoTextBox Or shp.Type = msoPlaceholder Then
                For cnt = 1 To Len(shp.TextFrame.TextRange.Text)
                    If shp.TextFrame.TextRange.Characters(cnt, 1).Font.Color = lngOldColor Then
                        shp.TextFrame.TextRange.Characters(cnt, 1).Font.Color = lngNewColor
                    End If
                Next
            'ElseIf shp.Type = msoPlaceholder Then
            End If
        Next
    Next
End Sub

Sub ChangeColor()
    changeText Val("&h0000B4"), vbGreen
End Sub

Open in new window

CERTIFIED EXPERT
Top Expert 2011

Commented:
Can you supply a copy of your file, (remove sensitive data) that I can test since although it worked in my tests clearly there is something I missed and that needs sight of the document.

If you are concerned about this forum visibility, I have an email in my profile you can send it to and I will make sure the issue is identified in this thread without anything sensitive once it works for me.

Best however is posting a safe copy herein since then many experts can help!

Chris

Author

Commented:
It does not allow .pptm files to uploaded.

Can you gibe me email address?

Author

Commented:
I renamed the extension to .ppt (from .pptm)
Hope it works.  EE.ppt
CERTIFIED EXPERT
Top Expert 2011

Commented:
Save as 97 PPT type and that should be allowed otherwise

Not allowed to place addy in a thread as these are searchable, but click my name ... this will display my profile, and the address can be gleaned therein as address@domain.com with both parts visible therein.

Chris

Author

Commented:
Does the file I just uploaded work you after renaming the extension?
CERTIFIED EXPERT
Top Expert 2011
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Great!
So 11796480 is RGB in decimals?

Author

Commented:
Sorry, what exactly is that number?
CERTIFIED EXPERT
Top Expert 2011

Commented:
That's the actual color of the font text that was colored blueish in the original file.  I established what it was by direct read of the data within vba.

For what it's worth:

?val("&h0000B4")
 180

i.e. nothing like the actual font color but it needs to pretty much exact although there is some potential to use a wild card that says blueish / redish if necessary.

Chris

Author

Commented:
But how do I get these numbers. i.e how do I convert from RGB to that number?
Is it just converting a hex no to decimal?
CERTIFIED EXPERT
Top Expert 2011

Commented:
Conversion from RGB is as I showed ... what I suggest is teh hex value you provided was not the correct one for the text.  For example how did you get the value h0000B4 that you supplied?

Chris

Author

Commented:
That's the HTML code for that color.
So if my RGB values for my color are (230, 240, 250), how do I convert this to a form VBA understands?
CERTIFIED EXPERT
Top Expert 2011
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Great! Thank you so much!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.