Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Convert iWork '09 files to Office or PDF files via droplets Apps
Snow Leopard only hintIf you use iWork extensively, you may frequently face the need to convert your iWork files into either Microsoft Office or PDF files to share with colleagues, either via email or by posting to a website. It's tedious to have to convert them one-by-one, so I put together two droplet scripts to automate the process. They will convert Pages to Word, Keynote to PowerPoint, and Numbers to Excel, or any of the iWork types to PDF, and do it for multiple documents (even of different original types).

A couple of notes about the scripts given below:

  1. These are for iWork '09 on OS X 10.6. I doubt they will work properly for anything earlier.
  2. The scripts create the converted files on the Desktop, with the same file names and an extension matching their converted form. They will overwrite identically-named files on the Desktop without asking.
  3. The scripts try to be intelligent about leaving the iWork apps in the same state they started in -- if an app was not running before conversion, the script will quit it after conversion. Likewise, if the document you're asking to convert was open, the script will leave it open, but if the script had to open it, it will close it when finished.
  4. Keynote is a bit brain dead about conversion, thus requiring UI scripting to get it to convert things properly -- you'll need to have 'Enable Access for Assistive Devices' enabled in the Universal Access System Preferences panel. If you're reproducing or editing these scripts, note that the name of the buttons "Export…" and "Next…" contain single ellipsis characters. They can be typed with Option-; (semicolon) on a US keyboard.
Here are the scripts (100KB download). I'm not including the scripts here in the text because they're kind of long, and get a bit repetitive. [macosxhints.com mirror]

Extra geeky note: Keynote can be made slightly less brain dead for the conversion to PowerPoint case. If you edit Keynote's Info.plist file to include Microsoft PowerPoint 97 - 2004 presentation for Exportable as Document Type Names under the relevant document type definition for .key files, the iWork to Office script can eliminate UI scripting and just save files analogously to the way Pages and Numbers do it. That does not, however, work for Keynote to PDF conversions.

Credit: Much of the hard work was done by the folks at the following two pages:
  1. The general pattern of the scripts
  2. The UI scripting for Keynote
[robg adds: I haven't tested this one; I did mirror the scripts here on macosxhints.com, just in case the original ever vanishes.]
    •    
  • Currently 2.82 / 5
  You rated: 1 / 5 (22 votes cast)
 
[24,678 views]  

Convert iWork '09 files to Office or PDF files via droplets | 9 comments | Create New Account
Click here to return to the 'Convert iWork '09 files to Office or PDF files via droplets' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Convert iWork '09 files to Office or PDF files via droplets
Authored by: spiliog on Feb 10, '10 08:37:05AM

So, how can I use the scripts? (excuse my ignorance)



[ Reply to This | # ]
Convert iWork '09 files to Office or PDF files via droplets
Authored by: Supp0rtLinux on Feb 10, '10 10:12:20AM

@spilog... here's what I did:

1) Download and extract the zip file. You'll have the original scripts (editable with Apple Script Editor) and the compiled scripts.
2) Make a sub-folder of your home directory called "scripts" and save them there.
3) Open up Finder and drag them into your toolbar (the compiled scripts... the ones without the .scpt extension).
4) In the Finder window, click View | Customize Toolbar and place them how you want, add dividers, etc.

In the future... anytime you're browsing through files in Finder, you can drag 'n drop the file onto the script in your toolbar and it will convert and save the converted file on your desktop. Personally, I prefer to use iWork, but having to export into a compatible format for sharing w/ Office users is a pain (not sure why you have to do File | Export then answer a hundred questions... you should be able to just do File | Save As... and have one of the options be "Office Compatible Format"... but I digress). These scripts make it very convenient... I don't have to convert all my files, but if I do need to, I just drag the iWork file to the script in the Finder toolbar, then find the file on my desktop...



[ Reply to This | # ]
Convert iWork '09 files to Office or PDF files via droplets
Authored by: ssawyer on Feb 10, '10 10:51:54AM

That'll work fine, or just place the compiled script app (or an alias to it) on the desktop or in the Dock and drop files to be converted onto it.



[ Reply to This | # ]
Convert iWork '09 files to Office or PDF files via droplets
Authored by: neobobkrause on Feb 10, '10 09:06:24AM

Can somebody provide clearer instructions on how I modify Keynote's Info.plist to easier conversions to Powerpoint. Thanks.



[ Reply to This | # ]
Convert iWork '09 files to Office or PDF files via droplets
Authored by: ssawyer on Feb 10, '10 10:48:07AM
If you don't already know a good bit about this, I wouldn't bother, since you'd have to modify the scripts given anyway, and if you do it wrong, you could seriously screw up Keynote. I mentioned it mainly as a technical curiosity for people working with scripting the iWork suite.

But here are the particulars:

  1. Locate Keynote.app in Finder. Right- or control-click and choose "Show package contents"
  2. Open the Contents folder that shows. Then open the Info.plist file in Property List Editor.
  3. Drill down into the "Document Types".
  4. Under "Item 0" (BGDocumentTypeShow), add a child item named "Exportable As Document Type Names" to the bottom of its property list.
  5. Within that new child item, add an "Item 0" with the value "Microsoft PowerPoint 97 - 2004 presentation"
  6. Repeat the above 2 steps in Item 1 (BGDocumentTypeSingleFileShow).
Do all of the above without having Keynote open.

You'll then need to revise the scripts I included. In the iWork to Office script, you'll need to replace everything inside the else if (theExtension is equal to "key") then block with the following:

	set docPathAndName to docPathAndName & ".ppt"
	tell application "Keynote"
				
		-- check if document is already open
		set targetDocument to null
		repeat with aDoc in slideshows
			if (name of aDoc) is equal to theOriginalName then set targetDocument to aDoc
		end repeat

		-- if not, open it
		if targetDocument is null then
			open aFile
			set fileOpened to true
			set targetDocument to front slideshow
		else
			set fileOpened to false
		end if
		
		-- convert it
		save targetDocument as "Microsoft PowerPoint 97 - 2004 presentation" in docPathAndName
		
		-- close it if necessary
		if fileOpened then close targetDocument saving no
	end tell

Hope that helps, but use at your own risk.

[ Reply to This | # ]

Convert iWork '09 files to Office or PDF files via droplets
Authored by: thompss on Apr 08, '10 06:24:25PM

I'd REALLY find this useful, but I can't get the Keynote to Powerpoint to work. I have been looking for a batch converter like this for sometime.

It gives be an error about access to the device being denied....?

I am not adept at the script thing.

I am running Snow Leopard on a MBPro.



[ Reply to This | # ]
Convert iWork '09 files to Office or PDF files via droplets
Authored by: thompss on Apr 08, '10 06:32:15PM

Sorry, the exact language is, "Access for assistive device is disabled"

Any ideas?



[ Reply to This | # ]
Convert iWork '09 files to Office or PDF files via droplets
Authored by: thompss on Apr 08, '10 06:44:51PM

Ok I found part of what I was missing. I didn't read that whole post and saw that I had to enable the universal access. So I got it to work for one file.

But, I have a different question. I guess I misunderstood this and thought that this could convert multiple files. (i.e.. drag more than one on to the script instead of having to repeat this)

I work in a school, am one of two mac users, but want to share my files with other teachers. Instead of having to open and convert all one by one, I'd like to be able to tell the script to convert 5 or more, for example.

Is this even possible?



[ Reply to This | # ]
Convert iWork '09 files to Office or PDF files via droplets
Authored by: toboggan on Jul 18, '10 02:50:32PM

This script will let me do 99% of what I need to do with my iPad. Automated changing of iWork files to Excel or PPT and then Emailed back to me.

However, is there any way to change the script to save the resulting exported files in a folder of my choosing (not just the desktop)?

I looked but my Applescript skills are non-existant.

Thanks to anyone who can suggest how to change this.



[ Reply to This | # ]