Accepting revisions keeps inserted text and removes deleted text.
dotnet add package RecursiveAI.OneDocument.DocumentsRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using RecursiveAI.OneDocument.Documents; using var doc = Document.Open("review.docx"); doc.Revisions.AcceptAll(); doc.SaveAs("accepted.docx");
Writes accepted.docx; the snippet prints nothing.
Unzip the example, then dotnet run.
Full program
The included review.docx reads “Status: ” followed by Alex’s tracked deletion of “draft” and Sam’s tracked insertion of “approved”. Accepting both leaves “Status: approved”.
using RecursiveAI.OneDocument.Documents; using var doc = Document.Open("review.docx"); int accepted = doc.Revisions.AcceptAll(); doc.SaveAs("accepted.docx"); Console.WriteLine($"Accepted: {accepted}"); Console.WriteLine(doc.ExtractText().Trim());
dotnet run prints:
Accepted: 2 Status: approved
Malformed revision markup can remain unresolved and is reported as docx.revision-unresolvable; a revision object from before an edit is rejected with ArgumentException.
Variations
Accept only one author’s changes
Take a selection from the current revision list, then accept it in one call. This accepts Alex’s deletion but leaves Sam’s insertion tracked.
using RecursiveAI.OneDocument.Documents; using var doc = Document.Open("review.docx"); var selected = doc.Revisions.Revisions .Where(change => change.Author == "Alex") .ToArray(); int accepted = doc.Revisions.Accept(selected); Console.WriteLine($"Accepted: {accepted}"); doc.SaveAs("alex-accepted.docx"); int remaining = doc.Revisions.Revisions.Count; Console.WriteLine($"Remaining: {remaining}");
Output:
Accepted: 1 Remaining: 1
Related recipes
The short answer
Call doc.Revisions.AcceptAll() and save the document to a new DOCX. Accepting changes mutates the document: inserted text remains as normal text, deleted text is removed, and revision records are resolved. It is not a display setting that merely hides markup.
In the sample, the deleted word “draft” goes away and the inserted word “approved” stays. The full program prints the number of accepted revisions and the resulting text. Keep the original review document if you might need to revisit the editorial decisions later.
How do I accept all tracked changes in Microsoft Word?
In Word, choose Review > Accept > Accept All Changes.
For a C# application processing a DOCX, use the revision model on Document rather than changing how revisions are displayed. AcceptAll resolves all revisions in its set; the model covers the body and revision-bearing parts such as headers, footers, notes and comments. The revision documentation details the supported markup.
Insertions and move destinations retain their content and lose their wrappers. Deletions and move sources lose both the wrapper and content. Formatting changes keep the current properties and discard the record of the previous properties. Table row and cell revisions can remove structure, not just words.
A deleted paragraph mark is another important case. Accepting it joins the paragraph’s content to the next paragraph, whose paragraph properties then apply. A mark that cannot be removed, such as one before a table or holding a section break, is only unmarked. Do not reduce revision acceptance to deleting every XML element with a revision-like name: the element’s parent determines what the revision means.
If you only need text as though changes had been accepted, RevisionSet.GetText(part, RevisionView.Accepted) gives a view without editing the file. That is useful for comparing text, but it does not produce an accepted DOCX. The view does not read text boxes or drawings. Use mutation followed by SaveAs when the output file itself must contain the accepted result.
What is the difference between accepting a change and accepting all tracked changes?
A selection resolves only its chosen revision records. AcceptAll resolves the complete current set. The author-filtered variation takes Alex’s revisions from the current list and passes them together to Accept; Sam’s insertion stays tracked. You can select by other revision metadata, such as kind, date, part or scope, when your review policy calls for it.
Selections must come from the current list. After an edit, OneDocument rebuilds the revision list and refuses old revision objects with ArgumentException. Gather a selection, resolve it in one call, then fetch a new list before the next decision. This also matters for nested revisions: accepting an outer insertion does not automatically resolve an inner deletion by another author.
A revision whose markup cannot be resolved stays in place and produces docx.revision-unresolvable. Check diagnostics and the remaining revision list rather than assuming a call removed every malformed record. Nothing outside resolved revisions is meant to change, and parts without revisions are not modified.
Accepting tracked changes is not general document sanitizing. It does not mean author properties, ordinary comments or hidden text have been removed. For a pre-sharing cleanup, inspect those categories separately or use the hidden-data recipe in addition to making the editorial decision about revisions.