With myPresentation.Slides(index).Shapes(1).TextFrame.TextRange.Text
.Left = (ActivePresentation.PageSetup.SlideWidth - .Width) / 2
.Top = (ActivePresentation.PageSetup.SlideHeight - .Height) / 2
End With
所以基本上我有一张带有1个标题对象的幻灯片,并且我正在尝试将其格式化为居中位置,
.Left = (ActivePresentation.PageSetup.SlideWidth - .Width) / 2
但是此行抛出对象必需错误。感谢您的帮助
答案 0 :(得分:0)
Shape
对象具有Left
,Top
,Width
和Height
属性。在这种情况下,TextFrame
,TextRange
和Text
无关。
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