简体   繁体   中英

VBA Error 429 'ActiveX can't create application object'

Hi Guyz I'm writing these lines of code with powerpoint but getting error 429

错误

pls help.

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

This may not fully solve your problem but assuming power point is installed you should be able to use late bound references all the way through as follows.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM