Colorize Nightmare

Canuckish

New Member
Joined
Jan 9, 2014
Messages
7
I have a presentation filled with shapes that are the "wrong" kind of red (thanks Marketing) and need to make them the "right" kind of red. A few problems:

1) I don't know what the red value "3747998" means when, with the first shape for re-coloring selected

debug.print ActiveWindow.Selection.ShapeRange.Fill.ForeColor
Worse still, there doesn't seem to be the ''record macro'' button in my PPT app, and

debug.print ActiveWindow.Selection.ShapeRange.Fill.ForeColor.RGB
gives the exact same 7-digit number


2)Once I get the value of the selected shape back, how do I do a loop through EACH shape in the deck with a loop, as in

"If the color value = 3747998 then make it RGB(181, 18, 27)"

Thanks for any help; I am using Excel 2010 on Windows 7.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try:
Code:
Sub ChangeColor()
    Dim sh As Shape
    For Each sh In Sheets("Sheet1").Shapes
        sh.Fill.ForeColor.RGB = RGB(181, 18, 27)
    Next sh
End Sub
Change the sheet name to suit your needs. By the way, this will change the color in all the shapes. I'm not sure if this is what you wanted.
 
Upvote 0
have you tried right clicking on shape, changing the colour and then using F4 to replay the action on the next shape you select (not 100% sure this will work in powerpoint)
 
Upvote 0
I'm not familiar with VBA in PowerPoint. You said you were using Excel 2010.
 
Upvote 0
This is my first time using vba in powerpoint, but I think I got it. This loops through all of the slides and for each slide it goes to each shape and determines if its color is 3747998. If it is then it sets the fill and outline color to the RGB value you gave. It works on a test presentation, but please be sure to try it on a copy of your presentation.


Code:
Sub test()

Dim allShapes As Shapes


For i = 1 To ActivePresentation.Slides.Count
Set allShapes = ActivePresentation.Slides(i).Shapes




For Each thisShape In allShapes
    If thisShape.Fill.ForeColor.RGB = 3747998 Then
        thisShape.Fill.ForeColor.RGB = RGB(181, 18, 27)
        thisShape.Line.ForeColor.RGB = RGB(181, 18, 27)
    End If
Next thisShape


Next


End Sub
 
Upvote 0
have you tried right clicking on shape, changing the colour and then using F4 to replay the action on the next shape you select (not 100% sure this will work in powerpoint)

Yes that would work, but it's a lengthy (automated) presentation and will soak up a lot of hours if I have to do it each time....
 
Upvote 0
didn't know how many you had to do :)
 
Upvote 0
This is my first time using vba in powerpoint, but I think I got it. This loops through all of the slides and for each slide it goes to each shape and determines if its color is 3747998. If it is then it sets the fill and outline color to the RGB value you gave. It works on a test presentation, but please be sure to try it on a copy of your presentation.


Code:
Sub test()

Dim allShapes As Shapes


For i = 1 To ActivePresentation.Slides.Count
Set allShapes = ActivePresentation.Slides(i).Shapes




For Each thisShape In allShapes
    If thisShape.Fill.ForeColor.RGB = 3747998 Then
        thisShape.Fill.ForeColor.RGB = RGB(181, 18, 27)
        thisShape.Line.ForeColor.RGB = RGB(181, 18, 27)
    End If
Next thisShape


Next


End Sub

This is awesome. One tiny question: how do I change it so that any shapes within shapes are also checked and changed? I.e. I have a table with shapes in it, same issue...
 
Upvote 0
Can you upload an example of a slide with a shape in the table? I'm not a powerpoint guru so I'm not sure what you mean.
 
Upvote 0

Forum statistics

Threads
1,215,494
Messages
6,125,139
Members
449,207
Latest member
VictorSiwiide

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top