Fun with the Word 2007 Document Format (docx) Print E-mail
  
Friday, 08 August 2008 15:43

Fun with the New Word 2007 Document Format

Here’s a little exploration of the new Word 2007 document format. It’ll give a little insight into how we can leverage this new format programmatically.

  1. Open Word 2007. A new document is created by default.
  2. Type “This is a test”.
  3. Drag and drop an image from your computer into the document. It should drop in a picture.
  4. Click the “Save” icon (little floppy) to save. Select Word Document (*.docx) as the “Save as type”, note the location where you’re saving the file, and then click Save.
  5. Close Word 2007

Find the file and explore it…

  1. Using the file browser (Explorer), fine the file you just saved in the file system. It’s probably called “This is a test.docx”.
  2. Rename the file by replacing the “docx” extension with “zip”. You’ll end up with “This is a test.zip”
  3. Open the ZIP file.

Changing it around a bit…

  1. In the ZIP file, browse to word/media.
  2. Drag a different image from your computer and drop it into the ZIP so it replaces the image1.jpeg that’s already in there.
  3. In the ZIP file, find the file word/document.xml, drag it onto the desktop or into a temp location, and then open it with Notepad.
  4. Find the string “This is a test” and replace it with “This WAS a test” and save the file.
  5. Drag document.xml back into the ZIP so that it replaces the original version.
  6. In the ZIP, find the file docProps/core.xml, drag it onto your desktop of a temporary location, and then open it with Notepad.
  7. Find the <dc:creator> tag and replace its contents (probably your name or username) with something like “Frank Sinatra” and save the file.
  8. Drag core.xml back into the ZIP so it replaces the original version.

Re-opening in Word 2007

  1. Rename “This is a test.zip” back to “This is a tet.docx”, and double-click it to open it.
  2. Note that the image and the content has changed. The image is stretched to the size of the original.
  3. Click the Office Button, which is the round button on the uppoer left corner of the window,
  4. Click Prepare, then Properties, and note that the author has changed.
Last Updated ( Friday, 08 August 2008 15:43 )
 

Offers

Google Tools

Gmail Docs Code Finance Maps Calendar

More Offers