Even though the adage is “A Picture is Worth a Thousand Words”, sometimes it is useful to supplement a Visio drawing with text. For simple reports, Visio has a Reports feature that will produce tables of information, but occassionaly I want something more. For example, Visio does not have a feature to compare what is different between two drawings, so I have created a routine that will generate a very verbose Word document (think Print ShapeSheet on steroids) that contains minute details of the drawing(s) and then used Word’s Compare Document feature to highlight the changes.
In the past I have written directly to the Word object model from Visio, but this tended to be painfully slow and would occassionally die (or be comatose). This was to be expected because the verbose Print ShapeSheet could end up being over two hundred pages long.
The next option was to just write a plain text file, but I missed the readability of having a formatted document, even if the formatting was just headers and page breaks. So I would intersperse the text with markers that would indicate the headers and where the page breaks belonged. I could then let Word open the text file and then run a macro to format the headers, add page breaks and remove extraneous lines. I did find that I needed to save the Word document before running the macro because running the macro against a raw text file was extremely slow.
At the first Microsoft Visio summit, my fellow MVP Chris Roth gave a demonstartion of how little XML code you needed to create a Visio drawing. I tried something similar with Word XML, but was never able to get an acceptable minimal set of XML tags. So creating an XML file that Word could consume was not a viable solution.
With Word 2007 and Excel 2007 came a new file format, a zipped directory of XML files. The OOXML format looked promising, but there were still way to many hoops to jump through to get a simple Word document.
Now with the release of the OOXML SDK 2.0, the actual creation of a Word docment is relatively simple. So if you need a way to create a Word document from Visio take a look at
How to: Create a Word Processing Document by Providing a Filename http://msdn.microsoft.com/en-us/library/ff478190.aspx