尝试将标题居中时,VBA for powerpoint出错(424:需要对象)
所以基本上我有一张有1个标题对象的幻灯片,我正试图将其格式化为居中尝试将标题居中时,VBA for powerpoint出错(424:需要对象),vba,powerpoint,Vba,Powerpoint,所以基本上我有一张有1个标题对象的幻灯片,我正试图将其格式化为居中 With myPresentation.Slides(index).Shapes(1).TextFrame.TextRange.Text .Left = (ActivePresentation.PageSetup.SlideWidth - .Width) / 2 .Top = (ActivePresentation.PageSetup.SlideHeight - .Height) / 2 End
With myPresentation.Slides(index).Shapes(1).TextFrame.TextRange.Text
.Left = (ActivePresentation.PageSetup.SlideWidth - .Width) / 2
.Top = (ActivePresentation.PageSetup.SlideHeight - .Height) / 2
End With
但是这行抛出了一个对象必需的错误。任何帮助都将不胜感激该对象具有、和属性<代码>文本框、文本范围
和文本
在这种情况下是不相关的
.Left = (ActivePresentation.PageSetup.SlideWidth - .Width) / 2
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