Search

VBA to get and print out color in Shapes

Print_Shapes_RGB
Related video: https://youtu.be/wbkNCUcRQLg

Option Explicit

Sub Print_Shapes_RGB()
Dim oSl As Slide, oSh As Shape
Dim iColor&, iRed&, iGreen&, iBlue&

Set oSl = ActivePresentation.Slides(ActiveWindow.Selection.SlideRange.SlideIndex)
For Each oSh In oSl.Shapes
   
   With oSh
   
      iColor& = .Fill.ForeColor.RGB
      iRed& = iColor& Mod 256
      iGreen& = iColor& \ 256 Mod 256
      iBlue& = iColor& \ 65536 Mod 256
      
   On Error Resume Next
    oSh.TextFrame.TextRange.Text = " = RGB(" & iRed& & "," & iGreen& & "," & iBlue& & ")"
    oSh.TextFrame.TextRange.Font.Size = 8
   End With
   
Next

Set oSl = Nothing
End Sub