views:

56

answers:

2

I have a requirement to build an MS Word 2007 plugin that provides a button which when clicked uploads the Word document to a webservice as XML.

So far this doesn't seem to be all that problematic but the customer has the additional requirement that they want the XML to be meaningful. They are recording formatted text but want certain areas of the document to be encompassed inside certain tags for example:

<WordDocument>
    <TagArea1>
        *word style xml for this bit of the document here*
    </TagArea1>
    <TagArea2>
        *word style xml for this bit of the document here*
    </TagArea2>
</WordDocument>

Their ideal is to have templates that they can define sections on that when uploaded create this style of XML.

The reason for using Word and not a form based technology is that keeping the formatting consistent is important and being able to choose where page breaks occur etc is vital to them.

I'm concerned that this type of functionality may not be possible but I'm quite new to developing inside Office applications so some pointers would be greatly appreciated.

+2  A: 

I'd upload it as a docx (zip file with xml + resources) and manipulate it using System.IO.Packaging. I know that you can do forms in Word, but I'm not sure exactly how that is represented in the docx xml. I'd start by creating a form in Word, use it, save it as a docx, then tear apart the XML to see what's in there.

In other words, I would use the facilities already present rather than try to hack together something.

Will
Another option instead of a saved docx package could also be to use the so-called Flat-OPC format (see http://blogs.msdn.com/ericwhite/archive/2008/09/29/the-flat-opc-format.aspx). This is e.g. available from the `ActiveDocument.WordOpenXML` property and also the format used when you develop a custom file export filter (see http://msdn.microsoft.com/en-us/library/dd300649.aspx). The flat OPC format has the advantage that you don't have to save a local copy of the document before you can upload it to the web service and that you can make modifications more easily, e.g. by applying an XSLT.
0xA3
That sounds like it might be a much simpler solution.
Will
+1  A: 

You could try use content controls (sdts) linked to your own XML part. Avoid the i4i patent mess though. See the Gray Knowlton post

plutext
+1 Content Controls were built with this specific scenario in mind and are probably the best choice.
Otaku