Is there a way to automate the generation of PowerPoint slides?

leora picture leora · Jan 26, 2010 · Viewed 17.3k times · Source

I have a bunch of data in a database and I want to generate some tables in PowerPoint. I had started doing this manually but I thought there might be a way I can simply write some code to take my data from the database and output it onto a PowerPoint slide.

Any advice here?

Answer

jsbueno picture jsbueno · Jan 26, 2010

You can certainly automate powerpoint trough the use of its XPCOM api -- (although, everytime I looked for documentation on the COM API for MS Office I haven't found it)

But, I'd suggest that instead of creating PowerPoint slides, you created Open Document presentations (ISO 26300 - .ODT files) - which are easy to undestand, parse and edit programatically -

.ODT files are the default presentation format for Open Office, Koffice, and other office software, and I think that Microsoft has come to support it by now - (although they have pushed ISO to approve their own proprietary specification of a similar format)

Anyway, editing the contents of a .odp file is trivial; the ODP file itself is a zipped archive, you unzip it, and edit the "contents.xml" file inside it -- creating new slides is a matter of copying the XML node corresponding to a slide and editing the desired text -- and pack everything inside a zip archive again.