Programmatically adjust shadow properties in PowerPoint

PowerPoint has two kinds of shadows - shape and text. Shape Shadows can be set by right-clicking on the shape (including the text box), choosing “Text Format”, then choosing “Shadow” or using VBA through the “Shadow” property in each shape:

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

How to set shadow text properties using VBA? You can get them in the user interface by right-clicking on the text, selecting “Text Effect Format”, then selecting “Shadow”. I did a bit of work on the Internet and could not find what features to access these properties can be accessed through the PowerPoint VBA API.

+3
source share
1 answer

You will need an object TextRange2. You can get this through the parent element TextFrame2. Here is an example of how you can set the shadow on the 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
+4
source

Source: https://habr.com/ru/post/1738077/


All Articles