DocumentTrackRevisions Property
True if changes are tracked when this document is edited in Microsoft Word.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
Syntax
public bool TrackRevisions { get; set; }

Property Value

Type: Boolean
Remarks

Setting this option only instructs Microsoft Word whether the track changes is turned on or off. This property has no effect on changes to the document that you make programmatically via Aspose.Words.

If you want to automatically track changes as they are made programmatically by Aspose.Words to this document use the StartTrackRevisions(String, DateTime) method.

Examples
Shows how to check if a document has revisions.
[C#]

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Normal editing of the document does not count as a revision
builder.Write("This does not count as a revision. ");
Assert.IsFalse(doc.HasRevisions);

// In order for our edits to count as revisions, we need to declare an author and start tracking them
doc.StartTrackRevisions("John Doe", DateTime.Now);
builder.Write("This is revision #1. ");

// This flag corresponds to the "Track Changes" option being turned on in Microsoft Word, to track the editing manually
// done there and not the programmatic changes we are about to do here
Assert.IsFalse(doc.TrackRevisions);

// As well as nodes in the document, revisions get referenced in this collection
Assert.IsTrue(doc.HasRevisions);
Assert.AreEqual(1, doc.Revisions.Count);

Revision revision = doc.Revisions[0];
Assert.AreEqual("John Doe", revision.Author);
Assert.AreEqual("This is revision #1. ", revision.ParentNode.GetText());
Assert.AreEqual(RevisionType.Insertion, revision.RevisionType);
Assert.AreEqual(revision.DateTime.Date, DateTime.Now.Date);
Assert.AreEqual(doc.Revisions.Groups[0], revision.Group);

// Deleting content also counts as a revision
// The most recent revisions are put at the start of the collection
doc.FirstSection.Body.FirstParagraph.Runs[0].Remove();
Assert.AreEqual(RevisionType.Deletion, doc.Revisions[0].RevisionType);
Assert.AreEqual(2, doc.Revisions.Count);

// Insert revisions are treated as document text by the GetText() method before they are accepted,
// since they are still nodes with text and are in the body
Assert.AreEqual("This does not count as a revision. This is revision #1.", doc.GetText().Trim());

// Accepting the deletion revision will assimilate it into the paragraph text and remove it from the collection
doc.Revisions[0].Accept();
Assert.AreEqual(1, doc.Revisions.Count);

// Once the delete revision is accepted, the nodes that it concerns are removed and their text will not show up here
Assert.AreEqual("This is revision #1.", doc.GetText().Trim());

// The second insertion revision is now at index 0, which we can reject to ignore and discard it
doc.Revisions[0].Reject();
Assert.AreEqual(0, doc.Revisions.Count);
Assert.AreEqual("", doc.GetText().Trim());

// This takes us back to not counting changes as revisions
doc.StopTrackRevisions();

builder.Writeln("This also does not count as a revision.");
Assert.AreEqual(0, doc.Revisions.Count);

doc.Save(ArtifactsDir + "Document.Revisions.docx");
See Also