vbapowerpointtextrange

How do you set the fill color of a TextRange?


In PowerPoint I have a TextRange object and I would like to set the fill color (not the font color).

I know given a shape I can set via Fill.ForeColor, but what about for a TextRange object?


Solution

  • You can't 'fill' a TextRange object but if you are trying to fill the text box that contains the TextRange then you fill the shape which is two parents above the TextRange object.

    e.g.

    Dim oShp as Shape
    Set oShp = ActivePresentation.Slides(1).Shapes(1)
    ' Fill the text with red
    oShp.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255,0,0)
    ' Fill the text box with green
    oShp.Fill.ForeColor.RGB = RGB(0,255,0)