Insert Word XML docs into another easily- I’m back from vacation!

OK- I am back from my long camping vacation. 5 sons, 4,100 miles, mini-van, tents, hospital. That's my summary of the vacation.

Anyway, a lot of people try to insert one Word XML document into another. Using XML methods on the OM seems to be popular. However, <w:cfChunk> is the best kept secret. Regrettably, there is little out there in this regard. It's mentioned here and there, but no one wants to explain how to use it. That's where I come in.

So, here's the scenario. I have doc1.xml and doc2.xml. They both have unique lists, styles, and fonts. I want to put the contents of doc2 into doc1, but I don't want to have to negotiate the import of all the styles, fonts, and list merging myself. Can't Word just do that for me? Yes. It can and it does.

Here's what you do- in doc1, find the spot where you want the contents of doc2 to appear. Instead of a <w:p>, put in a a <w:cfChunk></w:cfChunk>. Then, take all of the XML excluding the header stuff (bascially, the style, list, and font defs) along with the <body> section with everything in it (include the actual <body> tag!) and paste in the context-free chuck tag of doc1. Save the doc and open it in Word. The applicaiton will do the merging for you, and you have a clean, consistent doc1 with the whole of doc2. If you save doc1 and look at the XML, you will see that you do not have repeated header content. It's successfully merged.

 Rock Thought for the Day: My very best friend, Haini Wolfgramm, brought his wife and 7 kids to my home last Sunday, and he introduced me to the band 311. He had a DVD of one of the band's live shows. Excellent musicianship (occasionally hokey lyrics, though), and it is clear that they are so comfortable with their skills that they can include any influence they wish without being posers. They have a huge following, and thus have reached the rock band nirvana: being a sell-out to to the industry by providing the music you really want to make.

Rock On

Comments (6)

  1. Alexander Tarasul says:


    here is a problem I’m solving now.

    I need to edit rich text pieces in standalone windows application, save them into DB and insert into word document.

    My solution is RichText control, custom streaming into subset of WordML (bullets, bold, italic, underscore) and insertion of subset’s wordml into parent document – just between <w:p>

    I don’t like OLE embedding of word into Windows app.

    Any ideas?


  2. Jim says:

    I am from Minnesota, and in 1968 we traveled roundtrip to CA in a station wagon and a tent trailer — 6 of us kids and mom and dad.

    Your vacation sounds worse.

  3. Take a Guess...8) says:

    mmmm…Dry Rub Ribs…mmmm

  4. Alexander says:

    Just spoke with support and found a huge limitation. There is no way to insert WordML formatted rich text into excel cell. Actually excel "rich" text inside cell support not WordML schema as one could expect, but HTML4.0 and to be specific just 4 tags from HTML – bold, underline, italic and font.

    A lot of work ahead for Office XML – hope that version 12 will be better.

  5. Daniel Tse says:


    Does cfChunk include all forms of XML like AML used for tracking changes?

    I’m encountering a situation where I want to merge a copy of an altered document with a local reference copy-both may contain AML and I was wondering what I might be able to use to merge the entries. <w:cfChunk> looks like it might do something similar. Thoughts?

  6. Daniel, I’ll check it out.

Skip to main content