Aspose.Words

Manage Tracking Changes

This article outlines how Aspose.Words supports the Track Changes feature of Microsoft Word.

The Track Changes feature (also called Reviewing) in Microsoft Word allows you to track changes to content and formatting made by users. When you turn this feature on, all inserted, deleted and modified elements of the document will be visually highlighted with information about who, when and what was changed. The objects that carry the information about what was changed are called "tracking changes" or "revisions".

The Comments feature in Microsoft Word is also related to tracking changes. It allows a user to add comment to any fragment of text in the document. Note that comments are completely independent from tracking changes.

Aspose.Words Preserves Comments and Revisions

When you use Aspose.Words to open a Microsoft Word document and then save it, all comments and revisions in the document are preserved.

Accept Revisions

The Document.AcceptAllRevisions method allows you to "accept" all revisions in the document. Calling this method is similar to selecting "Accept All Changes" in Microsoft Word. Aspose.Words will actually delete fragments that were "delete revisions", retain fragments that were "insert revisions" and apply formatting changes. Note that comments are not affected during this operation.

In Aspose.Words, you can accept tracking changes of the document by calling Document.AcceptAllRevisions.

Example AcceptAllRevisions

Shows how to accept all tracking changes in the document.

[Java]

 

Document doc = new Document(getMyDir() + "Document.doc");

doc.acceptAllRevisions();

 

 

You can also check if a document has any tracking changes using the Document.HasRevisions property.

Programmatically Access Revisions

There could be insert, delete and formatting change revisions in a Word document. Aspose.Words allows you to programmatically detect certain types of revisions.

The Inline.IsInsertRevision and Inline.IsDeleteRevision properties available for the Run and Paragraph objects allow you to detect whether this object was inserted or deleted in Microsoft Word while change tracking was enabled.

The Document.HasRevisions property returns true if the document has at least one revision.

The Document.TrackRevisions property can be set to true to indicate whether the revision tracking in Microsoft Word will be enabled. Note that this setting does not affect the changes made to the document using Aspose.Words. Changes made to the document using Aspose.Words are never tracked as revisions.

Programmatically Access Comments

Comments are represented in the document tree as objects of the Comment class. You can add, delete or modify comments programmatically like any other node in Aspose.Words Document Object Model. Comment is a composite node and can contain paragraphs and tables that constitute the text of the comment. The Comment class also provides access to the name and initials of the author of the comment.