?
Solved

Change color

Posted on 2011-04-19
33
Medium Priority
?
527 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!
0
Comment
Question by:dshrenik
  • 16
  • 10
  • 6
  • +1
33 Comments
 
LVL 23

Expert Comment

by:JSRWilson
ID: 35426602
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?
0
 

Author Comment

by:dshrenik
ID: 35426657
It is the same everywhere. It does not follow the master slide. I changed colors manually.
0
 
LVL 23

Expert Comment

by:Brian Gee
ID: 35426797
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.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 23

Expert Comment

by:Brian Gee
ID: 35427680
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.
0
 
LVL 23

Expert Comment

by:Brian Gee
ID: 35429853
^ 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.
0
 

Author Comment

by:dshrenik
ID: 35430881
@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!
0
 
LVL 23

Expert Comment

by:Brian Gee
ID: 35430919
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.
0
 

Author Comment

by:dshrenik
ID: 35430944
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.
0
 
LVL 23

Expert Comment

by:Brian Gee
ID: 35430969
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...
0
 

Author Comment

by:dshrenik
ID: 35431254
Would it be possible to do it with VBA?
0
 
LVL 23

Expert Comment

by:Brian Gee
ID: 35431271
I'll try to explore this tomorrow... that is, if no one else does so before then.
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35431282
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

0
 

Author Comment

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

Author Comment

by:dshrenik
ID: 35431328
How do I view the changes made by the macro? Will it happen automatically, as soon as I save it?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35431335
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

0
 

Author Comment

by:dshrenik
ID: 35431340
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?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35431354
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

0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35431362
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
0
 

Author Comment

by:dshrenik
ID: 35431390
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

0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35431406
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
0
 

Author Comment

by:dshrenik
ID: 35431443
It does not allow .pptm files to uploaded.

Can you gibe me email address?
0
 

Author Comment

by:dshrenik
ID: 35431466
I renamed the extension to .ppt (from .pptm)
Hope it works.  EE.ppt
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35431469
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
0
 

Author Comment

by:dshrenik
ID: 35431477
Does the file I just uploaded work you after renaming the extension?
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 2000 total points
ID: 35431497
Fixed that one ... also changed the 'old' text color since the value you stated wasn't there.

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
                If shp.TextFrame.HasText 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
                End If
            End If
        Next
    Next
End Sub
Sub ChangeColor()
    changeText 11796480, vbGreen
End Sub

Open in new window

0
 

Author Comment

by:dshrenik
ID: 35431507
Great!
So 11796480 is RGB in decimals?
0
 

Author Comment

by:dshrenik
ID: 35431509
Sorry, what exactly is that number?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35431535
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
0
 

Author Comment

by:dshrenik
ID: 35431545
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?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35431567
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
0
 

Author Comment

by:dshrenik
ID: 35431582
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?
0
 
LVL 59

Assisted Solution

by:Chris Bottomley
Chris Bottomley earned 2000 total points
ID: 35431592
OK, I understand now ... see below.

Chris
Sub ChangeColor()
    changeText RGB(0, 0, 180), vbGreen
End Sub

Open in new window

0
 

Author Comment

by:dshrenik
ID: 35431611
Great! Thank you so much!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question