scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.39k stars 518 forks source link

run function on click #976

Open Patrick75010 opened 4 months ago

Patrick75010 commented 4 months ago

Is it possible to define one function and run it on click ?

MartinPacker commented 4 months ago

That would have to be VBA. Unfortunately you can't inject VBA into a presentation using python-pptx. I seriously doubt you could inject it with your own code - as it's not plain text. (I'd love to be wrong on this.)

What I have done - and this might work for you - is put the VBA code in my template presentation. Then I've managed to call it on clicking on a shape. (My md2pptx code supports this approach. I don't think I did anything special to have the shape clickable other than what python-pptx already supports.)