首页 > 解决方案 > VBA 错误 429 'ActiveX 无法创建应用程序对象'

问题描述

嗨,Guyz,我正在用 powerpoint 编写这些代码行,但出现错误 429

错误

请帮忙。

Option Explicit

Sub ListSlideInformationInExcel()
Dim i, j As Integer

Cells(1, 1).Value = "slide number"
Cells(1, 2).Value = "Name"
Cells(1, 3).Value = "No. of shapes"

Dim appPower As Object
Set appPower = CreateObject("Powerpoint.Application")
Dim pPres As PowerPoint.Presentation

appPower.Visible = True

appPower.Presentations.Open "C:\Users\SUMIT\Downloads\Slide Show Demo.ppt"

For i = 1 To pPres.Slides.Count
    j = 2
    Range("A" & j).Value = ActiveWindow.Selection.SlideRange.SlideIndex
    Range("B" & j).Value = ActivePresentation.Slides(i).Name
    Range("C" & j).Value = ActivePresentation.Slides(i).Shapes.Count
    j = j + 1
Next
End Sub

标签: vba

解决方案


这可能无法完全解决您的问题,但假设安装了电源点,您应该能够一直使用后期绑定引用,如下所示。

Option Explicit
Sub ListSlideInformationInExcel()
    Dim i As Long, j As Long
    With ActiveSheet
        .Cells(1, 1).Value = "slide number"
        .Cells(1, 2).Value = "Name"
        .Cells(1, 3).Value = "No. of shapes"

        Dim appPower As Object, pPres As Object
        Set appPower = CreateObject("Powerpoint.Application")
        appPower.Visible = True    
        Set pPres = appPower.Presentations.Open("C:\Users\SUMIT\Downloads\Slide Show Demo.ppt")
        'Other stuff
    End With  
End Sub

推荐阅读