0
votes

For word report generation, I am looking at binding XML to content controls to see if it is any easier than to use Word Interop and hardcode index reference to content controls to assign values to them.

However, I don't really understand how to do it.

My work flow is entering information in Excel and then generate an XML file to have content controls populated by XML, however, what I read is the other way round: Word Control Control Toolkit and descriptions where the XML is populated by user entering information in Word, and then programmer to unzip docx file to retrieve the XML file.

How can I populate content controls with XML?

2
This example maps custom xml to content controls using VBA: msdn.microsoft.com/en-us/library/office/gg605188.aspx You should be able to do something similar from Excel - I think the easiest would be to make a new docx based on a template with the content controls already in it.Olle Sjögren

2 Answers

0
votes

There are samples on generating Word documents from Word templates, XML and data bound content controls @ http://worddocgenerator.codeplex.com/

0
votes

Set up the mapped content controls in the 'template' docx using the content control toolkit or similar. Do this using a sample XML file containing your Excel data.

Now you have that template document, at run time you can inject your XML file into it (ie replace the custom xml part it contains, with your instance data), in C# or Java or whatever.

When the user opens the document in Word 2007/2010, the information in the custom XML part will automatically be copied into the bound controls, and visible to the user.

Note that content control data binding doesn't easily support repeating data (eg populating table rows) in Word 2007/2010, though there are ways to do it.