Programmatically Setting Text Shadow Properties in PowerPoint
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.Shad开发者_Python百科ow.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.
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
精彩评论