Delete an altChunk

Home Forums WordprocessingML Delete an altChunk

Tagged: 

This topic contains 0 replies, has 1 voice, and was last updated by  NehaS 8 years ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #3938

    NehaS
    Participant

    Hi Eric,

    I inserted an altChunk after a specific SDT(content control) in a document using the the same method as described in the link ” https://blogs.msdn.microsoft.com/ericwhite/2008/10/26/how-to-use-altchunk-for-document-assembly/ ” ( “Using V2 of the Open XML SDK” ). I want to delete the altChunk when I edit the document. This part I’m doing as follows –

    try
    {
    mainPart.DeletePart(mainPart.GetPartById(“AltChunkIdA1”));
    }
    catch (ArgumentOutOfRangeException e)
    { /*catch ArgumentOutOfRangeException which is thrown when the part with the specified id does not exist*/ }

    But the approach doesn’y seem to work out. Everytime I edit the document, the altChunk is not deleted. Instead a new altChunk with the same id gets added. The first time I create a document, the XML looks like this –

    After I edit the document, the XML is –

    So every time I edit the document, a new altChunk is added every time. Can you please help me with it and let me know where I’m going wrong.

    Thanks,
    Neha

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.