Hello Microsoft Word Blog?
Ok – I've got to admit, this feels a little strange. However, I've spent some time this week getting a feel for some of the developer features in Microsoft Office 2007, so I felt it was time I jump of the bridge and try writing and publishing a blog entry using Word 2007. You will know whether or not I am successful based on whether you can see this post – therefore, if you're reading this, everything worked fine.
I'm also quite happy that I decided to post via Word because (to my surprise) one of the underlying capabilities that (I think) enables this feature is something I've spent the majority of my research time on – XML data stores, content controls, and the OpenXML format for documents in all Office 2007 products.
So in case you were not aware, Office 2007 has dramatically changed in terms of how it stores and interacts with the documents it manages. For example, a Word document file used to be a single file containing binary data; later it became a single file containing XML data. With Word 2007, a document file is actually a zip file containing multiple XML (and potentially other types) files – each file manages a different part of the overall document. The feature that I was particularly interested in learning was how to create and add custom xml files to a Word document (package), and bind that data such that changing the data in the document actually changes my custom XML file, and changing my XML file actually changes the data in the document when it is running in Word. As I'm sure you can imagine, this capability opens up some huge possibilities in terms of new uses for Office tools like Word. Uses like…say…blogging?
Let me first say that taking advantage of XML data sources requires a bit of getting messy with the Word XML itself. I couldn't find any GUI-type tools for creating the data source or for mapping it to the document. Also, most of the samples surrounding data sources have to do with manipulating them programmatically. And while I think that programmatic manipulation is more typical, I wanted to understand exactly what I was manipulating. Therefore, I found a good example here. One quick gotcha if you want to follow this sample. First, there is a typographical error in the dataBinding XML tag. The actual tag should look like this.
<w:dataBinding w:prefixMappings="xmlns:ns0='http://www.contoso.com/2006/schemas/workdoc'" w:xpath="/ns0:projectDoc[1]/ns0:project[1]/ns0:consultantName[1]" w:storeItemID="{C66AC4F1-97D3-4D10-8D07-51E6CC79AD91 }"/>
Remember of course that the GUID you use for the store ID here needs to map to the GUID you declare in your itemProps file. Also, many thanks to Mike Ormond for helping me uncover the typos when I was at my wit's end. In order to keep from bugging Mike over and over in the future, I also came across this tool – it's a Windiff of sort for the new Office documents. Super cool!
Past that, there are a couple of major thing that I LOVE about maintaining my blog in Word.
- It's Word! I mean come on! Yes, you can do things like spell check in some of the server control/DHTML-driven editors out there – but all of those tools are simply trying to mimic Word – I like working off the original in this instance.
- Portability – one thing that always used to drive me a little nuts was that if I ever moved to a different blog, I had essentially lost all of the content that I had posted on that blog. My solution was typically to screen-scrape and save the results as a Word document. Again, it's much nicer when a post simply starts as a Word document.
- Automatic handling of posting images to the image library. I'll confess – I have not yet tried this. Perhaps I'll post a picture in a sec just to see how that works. What picture should I post? Hmm – thoughts for another entry…
And because I'm just really curious about whether the blogging feature is aided by custom XML data sources, I'm going to take a look. Be back in a second…
…Yup – check this out…
<?xml
version="1.0"
encoding="UTF-8"
standalone="yes"?>
<BlogPostInfo
xmlns="http://www.microsoft.com/Office/Word/BlogTool">
<PostTitle>Hello Microsoft Word Blog?</PostTitle>
<PostDate/>
<PostID/>
<Category1>Microsoft .NET Programming</Category1>
...
</BlogPostInfo>
Too cool!
I am currently the Editor-in-Chief for MSDN Magazine. I joined Microsoft in 2006 as a product planner with the certification team at Microsoft Learning. Prior to that, I spent my career as a developer and later as an architect. My main technology passions include pretty much anything on language theory, agile development, and service-oriented architecture.