尝试使标题居中时出现 VBA for powerpoint 错误(424:需要 object)

Error in VBA for powerpoint when trying to center a title(424: object required)

With myPresentation.Slides(index).Shapes(1).TextFrame.TextRange.Text
        .Left = (ActivePresentation.PageSetup.SlideWidth - .Width) / 2
        .Top = (ActivePresentation.PageSetup.SlideHeight - .Height) / 2
End With

所以基本上我有一张标题为 1 object 的幻灯片,我正在尝试将其格式化为居中,

.Left = (ActivePresentation.PageSetup.SlideWidth - .Width) / 2

但是这一行抛出一个 object 必需的错误。感谢任何帮助

Shape object has Left, Top, Width, and Height 属性。 TextFrameTextRangeText 在这种情况下无关紧要。

Option Explicit

Sub CenterTitle()
    Dim myPresentation As Presentation: Set myPresentation = ActivePresentation

    With myPresentation.Slides(1).Shapes(1)
        .Left = (myPresentation.PageSetup.SlideWidth - .Width) / 2
        .Top = (myPresentation.PageSetup.SlideHeight - .Height) / 2
    End With
End Sub