Showing posts with label office. Show all posts
Showing posts with label office. Show all posts

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.

20 September 2007

Batch converting Office 2007 documents to 2003 format


I had someone ask me today for a way to convert multiple docx files to plain old doc. Naturally I Googled for a solution (or should that be performed a web search using the Google™ search engine?) but I couldn't find one that I liked or was appropriate for someone a little less technically inclined. So I went ahead and rolled my own.

The result is a VBA macro enabled Word 2007 document. I have no idea if it works in any other versions of Word apart from the 2007 version although it might if the Compatibility Pack is installed. I do know that it probably won't work on anything apart from Windows because it expects folder names to end in a trailing backslash.

I should probably disclaim that I definitely am not responsible if this somehow messes something up. Use at your own risk! You can use this for whatever you like as long as you don't try to make money from it (not that you'd want to for this thing).

I should probably say that I hacked this together in a few minutes today. I've never used VBA before but take a look at the code if you want. You'll need to enable macros for this thing to work at all.

Download here!