Programmatically Accept or Reject Tracked Changes in Word

Before a business contract is signed, the two parties involved may have modified the document several times so as the both side can reach to an agreement. In order to know who’re changing what in your Word document, you can turn on Track Changes, and Accept or Reject the changes to get the tracked changes out of the document.

This article provides an easy solution in C# to accept or reject the tracked changes. Check below code snippets:

using Spire.Doc;
using Spire.Doc.Documents;

namespace AcceptOrRejectChanges
{
    class Program
    {
        static void Main(string[] args)
        {
            Document doc = new Document();
            doc.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.docx");

            Section sec = doc.Sections[0];
            Paragraph para = sec.Paragraphs[0];

            //accept changes
            para.Document.AcceptChanges();

            ////reject changes 
            //para.Document.RejectChanges();

            doc.SaveToFile("result.docx", FileFormat.Docx);
        }
    }

Result

2016-08-30_150234

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s