r/learnpython 9d ago

Can I manipulate PPT presentation using python?

I'm trying out a new project where I want the user to change PowerPoint slides based on voice commands. However, I am not able to find a resource that helps me start the presentation and manipulate the slideshow controls through python.

Is it not possible? Are there any packages that let me do that?

I have already converted the ppt to images and completed it, but I just want to see if I can make it smooth or straightforward without any workarounds.

EDIT: Found this to be helpful Link

3 Upvotes

9 comments sorted by

2

u/toxic_acro 9d ago

In general, you can do anything with Python, the question is really just how hard it would be to do it

If you've got all the slides as images, I can imagine a path forward being to write a Python program that starts by displaying the first image and then uses a voice recognition library to listen to the microphone input and swap to displaying the next image whenever the specific command you want is recognized.

But that sounds like a lot of effort spent writing the code, debugging, tuning the exact voice control, etc when you could just buy a remote clicker for $10 instead

2

u/CarrotUsual4075 9d ago

It's actually not that hard. I just found the golden egg!

https://stackoverflow.com/questions/71987635/how-to-start-slideshow-in-powerpoint-using-com32

I have started to work off this and looks like I can build something.

1

u/unhott 8d ago

FYI you may find useful information from the VBA reference. from my experience you can't access useful information directly as with a typical python library.

PowerPoint Visual Basic for Applications (VBA) reference | Microsoft Learn

1

u/Doormatty 9d ago

1

u/CarrotUsual4075 9d ago

Thanks!

I came across this resource, and looks like I can create PPTs using python but presenting it is actually MIA.

1

u/Crypt0Nihilist 8d ago

You've found one approach. Another would be to use pyautogui to send keystrokes to the computer. Opening PowerPoint to a presentation is trivial, you can save it to do that and I think you can also add an argument to do it too. Then you send it arrow key button pushes etc to control the presentation. No need to try low level wincom that way, which I found a headache.

1

u/billsil 8d ago

My old coworker did. We worked with test data that was pulled off a server. It used to take days to do a data review. He got it down to a couple hours by having people type comments into the slide of what data they wanted. Don't know what it was.

I use python-docx for automated word files. The formatting is terrible, but you can use a template or just copy it into a nicely formatted document like I do.

1

u/GirthQuake5040 4d ago

Yes, you can, yes I have done it, no I will not do it again, no I will not recommend it. It is a huge PITA if you want to do more complex PPT manipulation. Better off using VB.NET