vba - 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
解决方案
这可能无法完全解决您的问题,但假设安装了电源点,您应该能够一直使用后期绑定引用,如下所示。
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
推荐阅读
- javascript - 获得两个不同的日期月份
- c++ - sizeof(function) 有意义吗?
- html - 媒体查询未从 479px 到 767px 的宽度读取?
- python - 在 Python 中通过自省向模块动态添加函数
- android - firebase 与 android Instantapp 的集成
- python - **args 和 *kwargs 错误
- python - 正则表达式删除破折号后的 0
- javascript - 如何使 JavaScript 代码使用 ES6 工作?
- javascript - 我怎样才能使这个 Keyfunction 和 onload 函数工作?
- javascript - Angular 6:尝试区分“[object Object]”时出错。只允许使用数组和可迭代对象