I'm trying to print out a slide from Powerpoint. I've accessed the slide using the following code:
from win32com import client
powerpoint = client.Dispatch("Powerpoint.Application")
presentation = powerpoint.presentations.Open(filepath)
slide = presentation.Slides[10]
print(slide.name) # Just to check I have in fact got the slide
When printing Word docs I can just call PrintOut()
on the document but it doesn't seem to work for Powerpoint.
Does anyone have any solutions?
presentation.PrintOut()
prints the entire presentation, but I just want a specific slide.
Ok I figured out I can specify a range using:
presentation.PrintOut(From=1, To=1)
And I can iterate the slides to match the name using a loop:
count = 1
for slide in presentation.Slides:
if slide.name == "Slide1":
presentation.PrintOut(From=count, To=count)
break
count += 1