View Single Post
 
Old 09-08-2014, 09:33 AM
JohnWilson JohnWilson is offline Windows 7 64bit Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Some comments

In the first code your End If are not correctly placed. After checking for Purple the code will jump past the check for White which will never take place.

Try this instead

Code:
ub ChangeMultipleLineColors()

Dim sld As Slide, shp As Shape, PurpleColor As Long, WhiteColor As Long, BlackColor As Long, BlueColor As Long, Arr As Byte
Dim CheckColor As Long

'Set Colors
'These are not arrays so forget the (1)
PurpleColor = 16711807
WhiteColor = 16777215
BlackColor = 0
BlueColor = 12611584

For Each sld In ActivePresentation.Slides
    'sld.Select 'not necessary and not a good idea
    Debug.Print sld.SlideIndex    'again not necessary but useful if errors
    For Each shp In sld.Shapes
        If shp.Type <> msoGroup Then
            'shp.Select 'not necessary as above
            CheckColor = shp.Line.ForeColor.RGB
            Select Case CheckColor
                Case Is = PurpleColor
                    shp.Line.ForeColor.RGB = BlueColor    'Purple to Blue
                    shp.Line.Weight = 1.5
                Case Is = WhiteColor
                    shp.Line.ForeColor.RGB = BlackColor    'White to Black
                    shp.Line.Weight = 3    'Change Line Weight
            End Select
        End If
    Next shp
Next sld

MsgBox "All Done Richard! Have a good day."

End Sub
To select all the shapes of one color you need to understant that .Select will usually only select the last item.

Code:
Sub SelectBlueLines()

Dim sld As Slide, shp As Shape
' this selcts the purple lines in the sample
' you cannot select shapes on multiple slides
' so choose just one
Set sld = ActivePresentation.Slides(1)
' unselect anything already selected
ActiveWindow.Selection.Unselect
Debug.Print sld.SlideIndex    'again not necessary but useful if errors
For Each shp In sld.Shapes
    If shp.Type = msoLine Then
        ' When you select the default behaviour is to deselect anything already selected
        ' You will end up the last selection only UNLESS
        ' you specify "Do not replace"
        If shp.Line.ForeColor = RGB(127, 0, 255) Then shp.Select Replace:=msoFalse
    End If
Next shp
MsgBox "All Done Richard! Have a good day."

End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials

Last edited by JohnWilson; 09-09-2014 at 12:18 AM.
Reply With Quote