2. PowerPoint VBA apply Transparency to Text field

As we know, it is very easy to create a shape and apply transparency in PowerPoint. But when we try to achieve the same with Text Fields, like apply desired transparency, PowerPoint just does not not allow it. I don’t the reason why Microsoft did not think on this topic, but yes, its very much needed feature in PowerPoint.

One generic way to apply transparency to text fields is to convert them into shapes (draw a rectangle shape over text field and then fragment them together) and then apply transparency, but you cannot change the text content because they are shapes. So is there a way to apply transparency to text fields.? Definitely yes !! Using VBA.!! Below piece of VBA code will help you to achieve it. If you want to learn more about how to insert a VBA code into PowerPoint and how to assign it to a shape, you can read through this blog .

Sub setTextTransparency()

    Dim sld As Slide
    Dim shp As Shape
    Dim textRef As TextRange2
    Dim L As Integer

    For Each sld In ActivePresentation.Slides
        For Each shp In sld.Shapes
            If shp.HasTextFrame Then
                Set textRef = shp.TextFrame2.TextRange
                    For L = 1 To textRef.Characters.Count
                        textRef.Characters(L).Font.Fill.Transparency = Rnd * 1
                    Next L
            End If
        Next shp
   Next sld
End Sub

In the above code, the line ” textRef.Characters(L).Font.Fill.Transparency = Rnd * 1 ” will Random transparency (Rnd means Random) levels to each characters in the text fields. Below Image is a example of this random transparency.

You can change above line like below to achieve 50% transparency.

textRef.Characters(L).Font.Fill.Transparency = 0.5

Below Image will show different transparency values against their modified values.

Leave a Reply