|
Written by Alex Franke
|
|
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. - Open Word 2007. A new document is created by default.
- Type “This is a test”.
- Drag and drop an image from your computer into the document. It should drop in a picture.
- 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.
- Close Word 2007
Find the file and explore it… - Using the file browser (Explorer), fine the file you just saved in the file system. It’s probably called “This is a test.docx”.
- Rename the file by replacing the “docx” extension with “zip”. You’ll end up with “This is a test.zip”
- Open the ZIP file.
Changing it around a bit… - In the ZIP file, browse to word/media.
- Drag a different image from your computer and drop it into the ZIP so it replaces the image1.jpeg that’s already in there.
- 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.
- Find the string “This is a test” and replace it with “This WAS a test” and save the file.
- Drag document.xml back into the ZIP so that it replaces the original version.
- In the ZIP, find the file docProps/core.xml, drag it onto your desktop of a temporary location, and then open it with Notepad.
- Find the <dc:creator> tag and replace its contents (probably your name or username) with something like “Frank Sinatra” and save the file.
- Drag core.xml back into the ZIP so it replaces the original version.
Re-opening in Word 2007 - Rename “This is a test.zip” back to “This is a tet.docx”, and double-click it to open it.
- Note that the image and the content has changed. The image is stretched to the size of the original.
- Click the Office Button, which is the round button on the uppoer left corner of the window,
- Click Prepare, then Properties, and note that the author has changed.
|
|
Last Updated ( Friday, 08 August 2008 15:43 )
|