The Amazing World of COM

(2009)

COM is one of those things that I'd heard about but never really needed. Well yesterday I stumbled on a script for converting Word documents to PDF using COM and that got me thinking -- "Can I save myself TONS of time by writing a few scripts to do the really boring and repetitive parts of my job?". Indeed, the answer is yes.

Since Python is my first choice when there is a choice, I was pleased to discover the win32com package. Following is a very simple script using COM to convert Powerpoint slideshows from PPT to PPS (powerpoint show):

import os, win32com.client
doc_template_name = os.path.abspath('test.ppt')
doc_final_name = os.path.abspath('test.pps')
app = win32com.client.Dispatch("PowerPoint.Application")
app.Visible = True
doc_template = app.Presentations.Open(doc_template_name)
doc_final = app.Presentations[0]
doc_final.SaveAs(doc_final_name)
doc_template.Close()
app.Quit()

This script is heavily influenced by the many wonderful examples at: http://win32com.goermezer.de/