0

How we can create word document that is atemplate (contains paceholder to data ) and fill this template from xml document that contains data from serialized object

Mapping Word 2007 Content Controls to Custom XML Using the XMLMapping Object c#

3
Contributors
3
Replies
27
Views
2 Years
Discussion Span
Last Post by |-|x
2

In Word, Add Plain text Controls to your doc using the developer tab.
In VBA editor use function ActiveDocument.CustomXMLParts.Add and ActiveDocument.CustomXMLParts.Load to load your XML.

0

Thank you for your answer , and I need to ask how can progromatically do the same thing load custom xml parts into word using C#
Best Regards.

Edited by IsmailMBakr: not complete

0

You can instantiate an instance of the MS Word application via C# and programatically access all of the functions you would via the graphical interface. Your project needs to reference Microsoft.Office.Interop.Word and you must have word installed on the machine this will run on (ie; if it will be deployed on a server, the server needs to have Word installed).

To create the application instance:

Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();

Open the template document

Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(filename); // there are other optional parameters here you can check out

You can then access the doc.CustomXMLParts object, which should give you what you need.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.