views:

174

answers:

1

PowerPoint has two kinds of shadows - shape and text. Shape shadows may be set by right-clicking on a shape (including a text box), choosing Format Text, then selecting Shadow or using VBA via the Shadow property on each shape:

For Each Slide In ActivePresentation.Slides
  For Each Shape In Slide.Shapes
     Shape.Shadow.Size = 100
     ''# etc
  Next
Next

How do I set text shadow's properties using VBA? In the UI, these may be accessed by right-clicking on text, choosing Format Text Effect, then selecting Shadow. I've done a bit of digging online and have been unable to find where these properties may be accessed via PowerPoint's VBA API.

+4  A: 

You'll want the TextRange2 object to do so. You can get this through it's parent of TextFrame2. Here's an example of how you can set shadow's on text:

Sub setTextShadow()
Dim sh As Shape
Set sh = ActivePresentation.Slides(4).Shapes(1)
Dim tr As TextRange2
Set tr = sh.TextFrame2.TextRange
    With tr.Font.Shadow
        .OffsetX = 10
        .OffsetY = 10
        .Size = 1
        .Blur = 4
        .Transparency = 0.5
        .Visible = True
    End With
End Sub
Otaku
Thank you. Finding the info you provided is hard. I tried a bit of Googling and couldn't come up with it.
Ben Gribaudo
Happy to help Ben! Note also that if you just want to use the standard text shadow (the one available from the ribbon bar), you can use the `Dim tr as TextRange` (**not** `TextRange2`), and then `Set tr = sh.TextFrame.TextRange` (**not** `TextFrame2`) and then finally just `tr.Font.Shadow = True`
Otaku