It seems this issue was brought up and requested back in 2015 but I cannot find any updates on it. I'm trying to copy an entire slide (including its text and images) from another presentation into my working presentation by doing something like the following:
prs = Presentation('CurrentPresentation.pptx')
prs1 = Presentation('OtherPresentation.pptx')
# Wanted_Slide = prs1.slides[0]
New_Slide = prs.slides.add_slide(prs1.slide_layout[0])
But all this does is add a totally blank slide (with the wanted slide's background) with slide layout 0, which totally makes sense. I know that's not the right way to do it. I tried the below and it did add a slide, but it was just a duplicate one of what was already in the prs presentation (I guess I found a way to duplicate a slide already in the presentation inadvertently):
def Add_Slide(self):
xml_slides = prs.slides._sldIdLst
xml_slides1 = prs1.slides._sldIdLst
slides = list(xml_slides)
slides1 = list(xml_slides1)
xml_slides.append(slides1[0])
The above code is a manipulation of a slide delete method I found online.
Or does anyone have any sort of recommendation on how to completely copy a slide and all of its contents over to a working presentation?
I apologize if no developments have been made and this post is a rehash. Thank you in advance.
Open an existing presentation or create a new presentation that you want to insert slides into. On the Home tab, under Slides, click the arrow next to New Slide, and then click Insert Slides from Other Presentation. Select the presentation that you want to insert, click Insert all slides, and then click Insert.
After pasting a new slide into the slide thumbnails on the left, look for the "Paste Options" icon at the bottom-right of the new slide's thumbnail. Click on the icon and change the default setting to "Keep Source Formatting". Voila - two templates in the same presentation.
python-pptx¶ python-pptx is a Python library for creating and updating PowerPoint (. pptx) files. A typical use would be generating a customized PowerPoint presentation from database content, downloadable by clicking a link in a web application.
There's an issue in the library's repo that has some code to do this, but it's rough, it doesn't work for all cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With