Ahem… but I am actually customizing Word 2007…

An OpenXML Word 2007 Document in Visual Studio 2008 showing customUI.xmlAnd to further contradict my previous rants, it is possible to write a macro to load Word Document Parts. However, none of these contradictions hold comfortable solutions. First, you can see the XML file, customUI.xml, in my Normal.dotm template. All I had to do was to edit this file to customize the Word 2007 “Fluent” Ribbon. This is what I did:

  1. Use the Custom UI Editor Tool to generate the proper OpenXML parts in the Normal.dotm template to get me started writing raw XML against the Word 2007 application. I could have done this by hand using the tool mentioned in step 2 but was too “lazy.”
  2. Use the Open XML Package Editor in the VSTO 2008 Power Tools to write raw XML. Doing this in Visual Studio was easier on my eyes (larger, bolder fonts than the Custom UI Editor Tool) and I could use the customUI.xsd schema (in 2007 Office System: XML Schema Reference) to make writing faster (Intellisense support). Also I found out the hard way that it is better to write this XML in a separate file in case Word panics and auto-magically deletes all of my hard work! Visual Studio is a great XML file editor.
  3. Use the 2007 Office System Document: Lists of Control IDs to wade through the sea of “Fluent” fluxions. Utterly ridiculous but it helped.

Okay: and now the macro thing. This is the important call in the important line of code that makes loading Quick Parts (or Custom Quick Parts) automatable: Call Application.NormalTemplate.BuildingBlockEntries.Add(). So what’s my problem? The problem is that a Range containing my custom XML does not get saved properly. Sometimes elements named “unknown” come out from the Quick Part Gallery. You don’t understand what I am talking about? I can sympathize. It would take days upon days to explain to a Microsoft employee—even one on the Word 2007 team—what the hell I am talking about… My guess is that this “edge case” will be fixed by accident in a future release.

And, speaking of Microsoft employees, here’s a table of resources researched for this crap I am writing:

Reuse and distribute parts of a document This was first document that explained to me how to build a Building Block. “Building blocks are reusable pieces of content or other document parts that are stored in galleries.”
Office 2007 “Legacy’ Mode In case I want to admit that I can’t handle change: “No, it’s not really a secret setting. It’s an add-in for Office 2007 that will finally give IT admins relief from that one user who resists change in all possible forms.”
Customizing the Office 2007 Ribbon Somehow Word MVP, Bill Coan, wrote an article that misled me into thinking you could not customize the Word 2007 Ribbon without paying for it. Surely, that’s my fault…
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3) Frank Rice and Ken Getz: “Learn how to customize the 2007 Office Fluent user interface. Also learn how new features in Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System support RAD development of Ribbon customizations. (40 printed pages)”
Mapping Word 2007 Content Controls to Custom XML Using the XMLMapping Object

This article really has nothing to do with the Ribbon but is related to “custom XML”: “Office Word 2007 has no user interface (UI) to map controls to XML with one exception—SharePoint and Built-in properties listed in the Quick Parts | Linked Properties menu.”

My point? Developer tools are increasingly becoming more important (to me) for Word. It is not healthy to regard Microsoft Word as “the people’s” word processor.

XML: The Angle Bracket Tax A Jeff Atwood diversion: “XML is like democracy. Sometimes it even works.” I commend Microsoft for attempting to XML-lize a word processor, but working with this is still not fun…
Linux.com :: The wide world of Linux word processors This is a subtle admission that reading fonts comfortably in a Linux-based “free” word processor is not the greatest: “The font rendering in TextMaker is a thing of beauty, and is noticeably superior to the other programs in this review.”
How to: Create a Custom Building Block Gallery This is the article that showed that you can write a macro to load a Building Block.
Microsoft announces Open XML SDK roadmap When Microsoft writes about “[a] content object model including additional classes and methods for simplifying developer work within parts…” this responds directly to my GetStream() concerns in a previous entry.