我正在尝试制作一个宏,以使用“自定义布局”创建Powerpoint演示文稿。这是代码:
Sub PPT_Criar()
Dim ppApp As Object
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
Dim ppTextBox As PowerPoint.Shape
Set ppApp = CreateObject("PowerPoint.Application")
Set ppPres = ppApp.Presentations.Add
ppPres.ApplyTemplate "D:\Users\11111\Documents\Modelos Personalizados do Office\PRES.potx"
ppApp.Visible = True
ppApp.Activate
Set ppSlide = ppPres.Slides.Add(1, ppLayoutBlank)
ActivePresentation.Slides(1).CustomLayout = ActivePresentation.Designs(Theme2).SlideMaster.CustomLayouts(3)
ppSlide.Select
Set ppTextBox = ppSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 20, 100, 30)
With ppTextBox.TextFrame2
.TextRange.Text = EPS
.TextRange.ParagraphFormat.Alignment = msoAlignCenter
.TextRange.Font.Size = 26
.VerticalAnchor = msoAnchorMiddle
End With
End Sub
运行它时,出现错误
在“运行时错误'429'Activex组件无法创建对象”
ActivePresentation
行中。我尝试了其他方法来完成此操作,而在所有这些方法中,ActivePresentation
所在的位置我都会遇到相同的错误。
你知道是什么原因造成的吗?