I have a word document with some Text and Images. I want to copy the content of the word document into another word document using C#.
Thanks.
Try this. It should do the trick. This will copy all contents from first document to second document. Make sure both documents exists.
using (WordprocessingDocument firstDocument = WordprocessingDocument.Open(@"E:\firstDocument.docx", false))
using (WordprocessingDocument secondDocument = WordprocessingDocument.Create(@"E:\secondDocument.docx", WordprocessingDocumentType.Document))
{
foreach (var part in firstDocument.Parts)
{
secondDocument.AddPart(part.OpenXmlPart, part.RelationshipId);
}
}