Share via

PowerPoint Macro

Anonymous
2020-05-05T17:37:07+00:00

Hello, I'm looking for a PowerPoint macro that will identify the color of a shape (in this case a circle being used to indicate a project's status), and convert it to text ("Red", "Yellow", "Green" or "Blue").  The text will then get written to an excel file with other information from the PowerPoint slide. I have the macro to pull all the other text information from the slide but I am unable to figure out how to "get" the color from the shape and translate to a text string.  Thank you.

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Steve Rindsberg 99,166 Reputation points MVP Volunteer Moderator
2020-05-06T16:48:20+00:00

Assuming that you set the colors in advance to *specific* values, you can do something like this:

Function ColorToString(osh As Shape) As String

    With osh.Fill.ForeColor

        If .RGB = RGB(255, 0, 0) Then

            ColorToString = "RED"

        End If

        If .RGB = RGB(0, 255, 0) Then

            ColorToString = "GREEN"

        End If

        If .RGB = RGB(0, 0, 255) Then

            ColorToString = "BLUE"

        End If

    End With

End Function

Sub TestMe()

    Dim osh As Shape

    For Each osh In ActiveWindow.Selection.ShapeRange

        Debug.Print ColorToString(osh)

    Next

End Sub

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2020-05-06T18:53:07+00:00

    Thank you.  I will give this a try.

    Was this answer helpful?

    0 comments No comments