24 November 2008

Modifying multiple motion paths in PowerPoint

or Why having human readable file formats is a Good Thing.


Recently I was creating a PowerPoint presentation to demonstrate a web site I had been developing. As I've discovered over the years, it's a wise thing to use PowerPoint, or rather screenshots of some sort, because it minimises the chance of something crashing or doing something equally as nasty.


What I wanted PowerPoint to do was to scroll everything up, like scrolling a page on a website. So I selected everything and then added a motion path. What I ended up with is something like this:


 
Each slide element has its own motion path. What I wanted was for each motion path to be exactly the same length, so that the scroll effect would look real - and the default length was not long enough. I tried shift-selecting all the paths and then extending each one by one but it didn't work.
So naturally, being who I am, I decided to try playing with the PresentationML (or "pptx" if you like) file format to see if there was anything I could do there. I started by saving the presentation and renaming it to have a .zip extension and then extracted it to see what I could find.

Basically I looked around the folder structure, trying to find some XML that might be describing the motion paths - and I found it. Inside the ppt\slides folder there are a number of XML files, each of which describes a slide in the presentation. I opened up my slide and looked around.

Here's something interesting:
   origin="layout"
   path="M 0 0  L 0 -0.33333  E"
   pathEditMode="relative"
   ptsTypes="">
This was present a number of times, and seems to be relatively self explanotory. It would make sense that -0.33333 would indicate the path was to go up (negative) by 0.33333 (whatever that represents). So I did a find replace for the path, replacing -0.33333 with -0.5 and re-zipped up the pptx contents. Sure enough, I find that all of my motion paths have grown in length and for me, -0.5 happened to be just right:



Just goes to show, human readable file formats can work wonders. Maybe there was a better way to do it within the UI, I don't know. But really, XML is Fun.