2

How can I accept all revisions in .docx file using Open XML SDK for .NET? I've tryed to use this example from Microsoft's Open XML SDK, but that code does't handling many cases, such as:

  • removed row from table is still present in document after accepting revision
  • removed item from unordered list is still present in document after accepting revision
  • removed empty paragraphs is still present in document after accepting revisions

Is there an easy way to accept all revisions or I should only manually catch and handle all possible cases?

1
  • I suggest to google for Eric White blog posts and videos on that. I believe he was the one who wrote that document you have linked. Had to work on this in the past, it's a tough one. Commented Jan 31, 2019 at 15:23

1 Answer 1

3

Following up on the comment from Michael Daniloff, Eric White is the current maintainer of the OpenXmlPowerTools project which provides a C# library for accepting the changes (see this example). Here's a small example of how to use it:

using DocumentFormat.OpenXml.Packaging;
using OpenXmlPowerTools;

public static void AcceptRevisions(string file_name) {
    using(WordprocessingDocument doc = WordprocessingDocument.Open(file_name, true))
        RevisionAccepter.AcceptRevisions(doc);
}

This handles the additional cases that the original Microsoft example missed (like table formatting changes, etc.).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.