4

Problem:

I'm trying to duplicate a slide from a presentation to another presentation, but it returns error:

Traceback (most recent call last):

File "C:\Users\vuse1\documents\visual studio 2015\Projects\PythonApplication\PythonApplication\PythonApplication.py", line 8, in  
 prs2.slides.add_slide(copySlide) 
File "C:\Python27\lib\site-packages\pptx\slide.py", line 287, in add_slide
  slide.shapes.clone_layout_placeholders(slide_layout) 
File "C:\Python27\lib\site-packages\pptx\shapes\shapetree.py", line 515, in
  clone_layout_placeholders for placeholder in slide_layout.iter_cloneable_placeholders():  
AttributeError: 'Slide' object has no attribute 'iter_cloneable_placeholders'

Code:

from pptx import Presentation

prs1 = Presentation("C:\\Users\\vuse1\Desktop\\first.pptx")
prs2 = Presentation("C:\\Users\\vuse1\Desktop\\second.pptx")

copySlide=prs1.slides[0]

prs2.slides.add_slide(copySlide)

prs2.save("C:\\Users\\vuse1\Desktop\\second.pptx")
stovfl
  • 14,998
  • 7
  • 24
  • 51
hod kakun
  • 41
  • 2

1 Answers1

0

Copying slides isn't officially supported by the library. There's a lot of discussion about this topic. Look at this github issue for workarounds.

Saleh
  • 173
  • 2
  • 12