System.Exception: Internal error 20, found element in OpenXmlPowerTools.RevisionAccepter.AcceptRevisions

Jul 20, 2015 at 11:49 AM
Edited Jul 20, 2015 at 11:50 AM
I want to Accept all the track changes from word document. I have written following codes to do so.
using (WordprocessingDocument wordDoc =
                           WordprocessingDocument.Open(filePath, true))

But above code is not working in some of the document. It shows System.Exception: Internal error 20, found element exception in some of the document.

So is there any issue with my word document? If yes then what should I look into document? In short I want to know that what is wrong with my document so that I can correct my document to run above code.

Another thing is that I am able to accept tracking changes in Word 2013/2010/2007 itself!!

Any help would be highly appreciated,
Jul 20, 2015 at 12:26 PM
Does your document validate successfully using the Open XML SDK? You can easily test this also using the Open XML SDK Productivity Tool, which you can download from MSDN.

Presuming that your document validates successfully, could you please attach your document to a post here, so I can determine what is wrong?
Jul 20, 2015 at 12:59 PM
Thanks for quick reply. Can you suggest me some link or code to check if document is validated or not using Open XML SDK Productivity Tool? And I cannot send the actual document because of business critical..
Jul 20, 2015 at 1:55 PM
Jul 21, 2015 at 4:58 AM
I have tried document using OpenXML SDK, and I am able to open document successfully. Also I have tried some operations like adding some paragraph using Open XML, Removing Comments from document, It is working fine. Is there any other thing which should I check with Open XML SDK?
Jul 21, 2015 at 5:23 AM
Without having the document, it is difficult to debug. Can you remove all sensitive information from the document, and then post it?
Jul 22, 2015 at 5:46 AM
Edited Jul 22, 2015 at 5:48 AM
Thanks for reply. You can get document from here. I am eagerly waiting for your reply. If it is not possible to stop this exception that request you to just tell me reason so then in future when I am creating document, I will take care about it.
Jul 23, 2015 at 6:37 PM
Here is a new RevisionAccepter that fixes the issue. Looking at the example, I can see why I never saw this issue. It occurs when there is a 'move-to' region immediately before a table, but where the contents of the 'move-to' were subsequently deleted after being moved. All of those conditions needed to be true in order for this to fail in this fashion. I have added xUnit tests for this circumstance, and this fixed RevisionAccepter will be in the next release of PowerTools, probably some time in the next 2 weeks.
Marked as answer by kalpesh_vaghela on 7/23/2015 at 9:15 PM
Jul 24, 2015 at 5:06 AM
Thanks you very much Eric. I really appreciate your help. Currently In my project I have directly added reference of OpenXmlPowerTools.dll in my project. Can you give me so insight like how can I integrate your updated RevisionAccepter.cs in my solution?
Jul 24, 2015 at 5:14 AM
I have copied your updated RevisionAccepter.cs File and called AcceptRevisions method from updated RevisionAccepter.cs and now it's working like a charm. Thank you very much again.
Jul 24, 2015 at 7:06 AM
Awesome! :)