Hi all,
I've written a macro which changes the border color of a shape in Powerpoint (toggling between pre-defined colors).
Now, this works fine, however, when a shape is grouped, the macro won't change the color of the shape (it will only change to black once (because of the ELSE statement) ).
Ideally, it would change color of the borders of all members/shapes in the group.
Ideally, one would select the group, and run the macro, and the outer shape changes the border color (Also see attached dummy powerpoint).
Does any of you know how to re-write the below to suit this?
Public Enum Color
PADPurple = 13964777 'RGB(233, 21, 213)
PADYellow = 49407 'RGB(255, 192, 0)
PADBlue = 15773696 'RGB(0, 176, 240)
PADBlack = 0 'RGB(0, 0, 0)
End Enum
Sub ChangeBorderColor()
'This macro can be used to quickly change image border colors in Powerpoint.
'It's advised to bind this macro to a keyboard shortcut (i.e. CTRL + > )
On Error GoTo Errorhandler
Dim myPic As ShapeRange
Set myPic = ActiveWindow.Selection.ShapeRange
Dim CurColor
If Not ActiveWindow.Selection.Type = 2 Then
Debug.Print ("Selected object is not a Shape type")
Exit Sub
End If
'Retrieve current border color
CurColor = myPic.Line.ForeColor.RGB
'Change color
Select Case CurColor
Case Color.PADBlack
Debug.Print ("Black > Purple")
myPic.Line.ForeColor.RGB = Color.PADPurple
Case Color.PADPurple
Debug.Print ("Purple > Blue")
myPic.Line.ForeColor.RGB = Color.PADBlue
Case Color.PADBlue
Debug.Print ("Blue > Yellow")
myPic.Line.ForeColor.RGB = Color.PADYellow
Case Color.PADYellow
Debug.Print ("Yellow > Black")
myPic.Line.ForeColor.RGB = Color.PADBlack
Case Else
myPic.Line.ForeColor.RGB = Color.PADBlack
Debug.Print ("Unknown color > Black")
End Select
Debug.Print ("Color changed")
Errorhandler:
End Sub
Thanks in advance!
A.
Bookmarks