vba 如何在 powerpoint 中改变对象的垂直和水平位置,例如艺术字?

How can vba be used to change the vertical and horizontal positions of objects, such as word art, in powerpoint?

我有很多幻灯片,每张幻灯片都有一个艺术字。我希望将艺术字与幻灯片的绝对中心对齐。我试过的代码是:

Option Explicit

Sub format()

    Dim sl As Slide
    Dim ob As Object

    For Each sl In ActivePresentation.Slides

        For Each ob In sl.Shapes
            With ob.TextFrame
                 '  .TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignCenter
                 '  .TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignMiddle
                 .HorizontalAnchor = msoAnchorCenter
                 .VerticalAnchor = msoAnchorMiddle

             End With

         Next ob

    Next sl

End Sub

也许会有帮助。

Option Explicit

Sub format()

Dim sl As Slide

    For Each sl In ActivePresentation.Slides
        sl.Shapes.Range.Align msoAlignCenters, msoTrue

        sl.Shapes.Range.Align msoAlignMiddles, msoTrue
    Next sl

End Sub