Need to use altchunk inside content controls and avoid UnknownOpenXMLElement error


  • Hi,

    I am using altchunk to merge multiple docx, I need to keep each merged document inside a content control,in the merging process described by Brian Jones here The Easy Way to Assemble Multiple Word Documents  content controls are removed  afeter inserting the altchunk to get a valid document since altchunk element cannot be a child element of SdtBlock and only can be a child of : body (17.2.2); comment (; docPartBody (17.12.6); endnote (17.11.2); footnote (17.11.10); ftr (17.10.3); hdr (17.10.4); tc (17.4.66) elements.

    As a solution to keep content controls and getting a valid document i am adding a table cell to the content control then the altchunk is added as child to the table cell but i have problem with imported docx containing tables and borders , borders for these documents are truncated, so this solution cannot be used, what I need to know is, can I ignore the UnknownOpenXMLElement errors related to altchunk parent element, knowing that generated document will be opened in word (so errors are corrected by word) because I cant find another solution ?


    • Modifié Tunisian_BB samedi 14 avril 2012 12:28 correction
    samedi 14 avril 2012 11:34

Toutes les réponses

  • Hi Tunisian_BB,

    Thanks for posting in the MSDN Forum.

    What's mean of "alchunk"? Do you clarify it?

    Have a good day,


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    lundi 16 avril 2012 03:10
  • AltChunk specifies a location within a document for the insertion of the contents of a specified file containing external content to be imported into the main WordprocessingML document. You can see at the MSDN AltChunk Class and this blog post How to Use altChunk for Document Assembly


    lundi 16 avril 2012 07:55
  • Hi,

    I have never been using altchunks myself to do document merging but I thought this is a most robust solution. Maybe you do something wrong. You can also use Docentric to do document merging. This toolkit is basically a data driven document generation solution but it is also able to merge sub documents into a main document. It doesn't use altChunks technique to do merging but instead does merging of all parts of subdocument with the main document so I suppose you won't encounter the same problems as with your curent technique.

    To do this with the toolkit you must create a template (main .docx document) and place the SubDocument elements (content controls with bindi) onto the template. Such an element can be placed anywhere in the template document. Then when generating the final document all SubDocument elements get replaced with the contents of the sub documents.

    lundi 16 avril 2012 08:12
  • I dont want to use a commercial product.


    jeudi 19 avril 2012 08:16