question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feature: delete a slide

See original GitHub issue

In order to modify an existing presentation to suit a new purpose As a developer using python-pptx I need the ability to delete a slide

API perhaps:

slides.remove(slide)

# OR

slides.remove(slide_a, slide_b, ...)
# alternately
slides.remove(*slides[2:4])

# OR

slide.delete()

Issue Analytics

  • State:open
  • Created 10 years ago
  • Reactions:6
  • Comments:35 (7 by maintainers)

github_iconTop GitHub Comments

10reactions
EBjerrumcommented, Apr 21, 2017

Thank you for the info as I also needed to delete some slides. based on @krzys-andrei work I made this function that deletes a slide object from a prs object.

def delete_slide(prs, slide):
    #Make dictionary with necessary information
    id_dict = { slide.id: [i, slide.rId] for i,slide in enumerate(prs.slides._sldIdLst) }
    slide_id = slide.slide_id
    prs.part.drop_rel(id_dict[slide_id][1])
    del prs.slides._sldIdLst[id_dict[slide_id][0]]
7reactions
krzys-andreicommented, Mar 16, 2017

thank you @jdgodchaux ! this successfully remove slides #22 to #118 from the pptx file :

for i in range(118,22,-1) : 
   rId = prs.slides._sldIdLst[i].rId
   prs.part.drop_rel(rId)
   del prs.slides._sldIdLst[i]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Add and delete slides in PowerPoint - Microsoft Support
Single slide - Right-click and select Delete Slide. · Multiple slides - Hold Ctrl and select the slides you want then right-click and...
Read more >
How to delete a slide in PowerPoint - Adobe
To delete a slide, simply highlight the slide you want to delete by clicking it in the left slide list and pressing either...
Read more >
How To Delete A Slide On Google Slides - TechNewsToday
Navigate to the slide you want to delete. Right-click on it and select delete from the list of options. The slide will automatically...
Read more >
How to delete a slide in Microsoft PowerPoint - PresenterMedia
Using your mouse, click on the preview of the slide you wish to delete. Next, right-click on the slide and select "Delete" from...
Read more >
Method to Delete a Slide in PowerPoint
Select the slide to be deleted and hit the "Delete" key on your keyboard; you can also right-click on a slide and choose...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found