I'm trying to copy slides from one PowerPoint presentation to another with the use of a VBA script in excel. Found the below code but when trying to run it I get the following error:
I'm working on 64 bit machine and I'm using the following references:
Sub Example2()
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
Could someone please help me overcome this error?
You have not declared a Powerpoint application object.
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