Class 未注册 VBA excel
Class not registered VBA excel
我正在尝试使用 excel 中的 VBA 脚本将幻灯片从一个 PowerPoint 演示文稿复制到另一个。找到了下面的代码,但是当尝试 运行 它时,我收到以下错误
我在 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\Desktop3.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\Desktop3.pptx")
'~~> Rest of the code
下面的工作代码
Sub Example2()
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\p123.pptx")
For i = 1 To objPresentation.Slides.Count
objPresentation.Slides.Item(i).Copy
objPowerPoint.Presentations.Item(1).Slides.Paste
objPowerPoint.Presentations.Item(1).Slides.Item(objPowerPoint.Presentations.Item(1).Slides.Count).Design = _
objPresentation.Slides.Item(i).Design
Next i
objPresentation.Close
End Sub
我正在尝试使用 excel 中的 VBA 脚本将幻灯片从一个 PowerPoint 演示文稿复制到另一个。找到了下面的代码,但是当尝试 运行 它时,我收到以下错误
我在 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\Desktop3.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\Desktop3.pptx")
'~~> Rest of the code
下面的工作代码
Sub Example2()
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\p123.pptx")
For i = 1 To objPresentation.Slides.Count
objPresentation.Slides.Item(i).Copy
objPowerPoint.Presentations.Item(1).Slides.Paste
objPowerPoint.Presentations.Item(1).Slides.Item(objPowerPoint.Presentations.Item(1).Slides.Count).Design = _
objPresentation.Slides.Item(i).Design
Next i
objPresentation.Close
End Sub