Accept All Changes in Word using C#

This article explains how to accept all changes in Word using C#. You will get the IDE configuration, a step-by-step description, and sample code showing how to accept revisions in Word using C#. It also shows how to explore the revisions collection and customize the process.

Steps to Accept Tracked Changes in Word using C#

  1. Set the IDE to use Aspose.Words for .NET to work with tracked changes
  2. Load the source Word file that contains tracked changes into memory using the Document object
  3. Display the number of tracked changes in the document before accepting them
  4. Call the Revisions.AcceptAll() method on the Document object
  5. Display the number of tracked changes again to confirm the acceptance

These steps describe how to accept changes in Word document using C#. Load the source Word file into the Document object and call the Revisions.AcceptAll() method to accept all the changes. Optionally, display the number of tracked changes before and after the process to confirm the operation.

Code to Accept All Tracked Changes in Word using C#

This code demonstrates a basic program showing how to accept all tracked changes in Word using C#. Before performing the task, you can check whether the document has tracked changes, turn off the document’s track changes feature to stop tracking future changes by setting the TrackRevisions property to false, and display each revision’s type, author, and date. You can also filter individual revisions with the Revisions.Accept() method, for example, to accept revisions from a particular author only. Similarly, you can accept all the revisions of a particular type or on a specified date.

This article shows how to accept the changes. To remove pages from the Word file, refer to the article Remove Pages from Word using C#.