gpt4 book ai didi

excel - 类未注册 VBA excel

转载 作者:行者123 更新时间:2023-12-04 21:45:08 28 4
gpt4 key购买 nike

我正在尝试使用 Excel 中的 VBA 脚本将幻灯片从一个 PowerPoint 演示文稿复制到另一个。找到下面的代码,但是在尝试运行它时我收到以下错误
enter image description here
我正在使用 64 位机器,我正在使用以下引用资料:
-Visual Basic 应用程序
-Microsoft Excel 16.0 对象库
-OLE自动化
-Microsoft Office 16.0 对象库
-Microsoft PowerPoint 16.0 对象库

Dim objPresentation As Presentation
Dim i As Integer

'open the target presentation
Set objPresentation = Presentations.Open("C:\Users\john\Desktop\123.pptx")
For i = 1 To objPresentation.Slides.Count
objPresentation.Slides.Item(i).Copy
Presentations.Item(1).Slides.Paste
Presentations.Item(1).Slides.Item(Presentations.Item(1).Slides.Count).Design = _
objPresentation.Slides.Item(i).Design
Next i
objPresentation.Close
End Sub

有人可以帮我克服这个错误吗?

最佳答案

您尚未声明 Powerpoint 应用程序对象。

Dim objPowerPoint As New PowerPoint.Application
Dim objPresentation As Presentation
Dim i As Integer

'open the target presentation
Set objPresentation = objPowerPoint.Presentations.Open("C:\Users\john\Desktop\123.pptx")

'~~> Rest of the code

关于excel - 类未注册 VBA excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68066199/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com