I am using Word and OpenXml to provide mail merge functionality in a C# ASP.NET web application:
1) A document is uploaded with a number of pre-defined strings for s
This piece of code should copy all parts from an existing document to a new one.
using (var mainDoc = WordprocessingDocument.Open(@"c:\sourcedoc.docx", false))
using (var resultDoc = WordprocessingDocument.Create(@"c:\newdoc.docx",
WordprocessingDocumentType.Document))
{
// copy parts from source document to new document
foreach (var part in mainDoc.Parts)
resultDoc.AddPart(part.OpenXmlPart, part.RelationshipId);
// perform replacements in resultDoc.MainDocumentPart
// ...
}