When you’re hand-editing Office files in Windows, it’s pretty straight-forward: unzip file > edit > rezip, you’re done. Editing in OS X requires a couple of extra precautions needed. This is because the graphical user interface adds Mac attributes to files and plants hidden files in folders. Office will not tolerate either of these:
If you use OS X’s Archive Utility to unzip or zip the files, Word will refuse to open the resulting file. On top of that, if you look in any of the folders using the Finder, a hidden .DS_Store file will be created in the folder. When re-zipped, Word will not accept the extra file and again report an XML error. The solution to these issues is to use the command line, like the Unix warrior you want to be! Remember to run each Terminal command by pressing the Return key after typing the command.
A valuable utility for this is OpenTerminalHere. Open any Finder window, click on OpenTerminalHere and a terminal window opens pointed to the Finder window. So download and install it, then follow these steps to open, edit and re-zip Office files:
- Move a copy of the Office document (let’s call it TestDoc.docx) to a separate folder and open that folder in the Finder.
- Click on OpenTerminalHere to open a copy of Terminal aimed at the folder.
- In the Terminal, type
then press Return. The file is unzipped into several folders plus a file called [Content_Types].xml.
- Do not look in any of the folders using the Finder, or you’ll have to start over. To examine a folder’s contents, use the Terminal to change the folder, then list the contents:
- To go back up to the previous folder, type:
- To edit the files, open your text editor, then navigate using the File>Open dialog to find the file. Edit the file, then save and close.
- When you’re all done, double-check that terminal is pointing at the original folder holding the documents and the expanded folders. If you’re unsure, close terminal, then click on OpenTerminalHere to reopen in the right spot.
- In Terminal, re-zip the files with this style of command:
zip -r RevisedDoc.dotx [Content_Types].xml _rels docProps word
This example is for Word, but the correct syntax after zip -r is to type the name of the final document, followed by the file and folders, each separated by a space. The file is reassembled into an Office file.
- Test that you can open it. If you get an XML error notice, re-read the above steps and try again.
Please note: these editing techniques are required when editing in OS X with Word, PowerPoint and Excel documents and templates, plus Office Theme files (the kind exported from PowerPoint that combine all Theme elements.
If, on the other hand, you are editing a Font Theme or a Color Theme, those are simple XML files. They don’t need to be unzipped or re-zipped and Office doesn’t seem to care about OS X attributes attached to them. These plain XML files don’t need to be handled through the terminal, just use the Finder.
Next time, we’ll be looking at managing Word styles in OS X. Finally, a way to get rid of the zombie styles automatically created by Word! Happy hacking!