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#
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#
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.
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.
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.