尝试使用自定义布局时出现ActivePresentation问题

时间:2019-06-25 19:37:37

标签: excel vba powerpoint powerpoint-vba

我正在尝试制作一个宏,以使用“自定义布局”创建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所在的位置我都会遇到相同的错误。

你知道是什么原因造成的吗?

0 个答案:

没有答案