[Python] Extracting text from a specific Powerpoint slide, without relying on slide order

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    I would like to be able to extract text from a specific slide of a .ppt file from Python, without knowing anything about slide order.

    Hence, there are two steps:

    1. How do I add an identifying feature to a specific slide (like adding a name to a range in Excel)?
    2. How to I access the slide by that identifying feature in Python?

    Preferably, the answer to (i) should not be something visible on the slide (ie. just like a range's name in Excel is not visible in the cells themselves).

    Below is an approximation of the form which the eventual answer to (ii) should take:

    from pptx import Presentation

    presentation = Presentation(<path to .ppt file>)

    slide = <enter method of retrieving the slide with the identifying characteristic from (i)>

    for shape in slide.shapes:
    <do something with shapes on the slide you have identified>


    Any thoughts would be welcome - many thanks!

    Continue reading...

Compartilhe esta Página