python-pptx icon indicating copy to clipboard operation
python-pptx copied to clipboard

I need move a slide from one ppt to another ppt

Open Lirioooo opened this issue 4 years ago • 4 comments

I've a project and one of the requirements is to move a slide from one presentation to another, but i can't to find a solution and i think to doesn't exists one, i need to do this with this code

prs = Presentation('ppt2.pptx')

for slide in prs.slides:
    for shape in slide.shapes:
        if hasattr(shape, "text"):
            for paragraph in shape.text_frame.paragraphs:
                for run in paragraph.runs:
                    if "Nuestra experiencia en su industria" in run.text:
                        url = "ppt2.pptx"
                        prsIndustria = Presentation(url)
                        slideAn = prsIndustria.slides[0]
                        slide = slideAn

I know that doesn't works like this but its a example. So help me with this please.

Lirioooo avatar Apr 01 '21 14:04 Lirioooo

Not possible with this library.

mszbot avatar Apr 08 '21 21:04 mszbot

I've solved this problem by iterating over the shapes in the source slide, copying them one by one and creating them in the dest slide. It's not an easy approach as you have to do a lot of manual work like copying over styles and contents and things like that, but for my use case it has worked just fine

qirh avatar Apr 19 '21 16:04 qirh

Do you have a working code snippet by any chance @mszbot please?

albertocalderari avatar Oct 15 '24 11:10 albertocalderari

There is no free library that provides this functionality, it's not simple. You can try aspose.com, powerpointgeneratorapi.com.

mszbot avatar Oct 15 '24 11:10 mszbot