Merging multiple word files (doc / docx) into one word file ?

Feb 10, 2016 at 11:50 AM
Hello,

I am interested to know if this could merge multiple word files ( doc / docx ) into a single word file.
I would also want to know how the formats are interpreted as file1 could have a different format structure ( margins , etc ) compared to file2. So I'm interested to know how the end result of this merge is considering these key properties. Things that interest me are how it handles the merging properties margin/indent/formats/font styles/ font size/ alignment/ page numbering/ header handling/ table of contents/ images positioning/ page breaks, etc.

Please let me know if it supports word files merging and how the end product result is formatted.

Kind Regards,
Alan
Feb 23, 2016 at 9:53 AM
Hi Alan,

This is exactly the purpose of the DocumentBuilder module in Open-Xml-PowerTools.

One key point - it only works with .DOCX, not .DOC. If you want to work with .DOC files you need to convert it to DOCX, but there are tools to do this:

https://blogs.msdn.microsoft.com/ericwhite/2008/09/18/bulk-convert-doc-to-docx/

For the DocumentBuilder module, please see:

http://ericwhite.com/blog/documentbuilder-developer-center/

With regards to styles, it takes the approach of using the definition of a style in the first document in the source documents in which the style occurs. So for instance, if there is are multiple documents with the style MyStyle, it takes the style definition from the first one it encounters. Subsequent documents will use that style.

You can avoid this behavior by renaming styles before merging, i.e. modify the second document to use the style MyStyle1 instead of MyStyle.

BTW, Open-Xml-PowerTools has been moved to GitHub. You can ask questions and file issues there:

https://github.com/OfficeDev/Open-Xml-PowerTools

Cheers, Eric