Blue Eyed Behemoth Blue Eyed Behemoth - 6 months ago 31
C# Question

Adding Complex Header From One Word Doc to Another

I am using the

function from The issue is that it's not taking any images or tables that might be found in the header section of the document. Is there a way to get everything from the header into the other document?


Using OpenXMLPowerTools I was able to use the following code to take the headers from one file and insert them into another:

var to = @"C:\Users\dheale\Desktop\Word Docs\_Blank_Skeleton.DOCX";
var from = @"C:\Users\dheale\Desktop\Word Docs\Letterheads\StandardLetterhead3.DOCX";
var outDoc = @"C:\Users\dheale\Desktop\Word Docs\test.DOCX";

var sources = new List<Source>
    new Source(new WmlDocument(to), false),
    new Source(new WmlDocument(from), true)

DocumentBuilder.BuildDocument(sources, outDoc);