Free Support Forum - aspose.com

TrackRevision on/off in Word

Hello. Tell me, please, I’m trying to include TrackChange in the Word file, to track the fixes. And after working with the document in offline take all the corrections (including notes) and stop tracking. For the first part, I use doc.TrackRevisions = true, for the second one I tried and doc.AcceptAllRevisions (); and doc.Revisions.AcceptAll (). But changes to the document do not apply, neither in the first nor in the second case, what do I do wrong?

if(context.Fayl != null){ 
	        		Document doc = new  Document(context.Fayl.ContentFilePath);
	        		doc.TrackRevisions = true;
	        		doc.Save(context.Fayl.ContentFilePath); 	
        	}
        	
        	if(context.Fayl != null){ 
	        		Document doc = new   Document(context.Fayl.ContentFilePath);
	        		doc.TrackRevisions = false;
	        		doc.AcceptAllRevisions(); 
	        		 //doc.Revisions.AcceptAll();
	        		doc.Save(context.Fayl.ContentFilePath); 	
        	}

@AlexBpm,

Thanks for your inquiry. When the value of Document.TrackRevisions property is true, changes are tracked when this document is edited in Microsoft Word. If you want to automatically track changes as they are made programmatically by Aspose.Words to this document use the Document.StartTrackRevisions method. Please use Document.StopTrackRevisions method to stop automatic marking of document changes as revisions.

Please check this following code example. Hope this helps you.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
                 
builder.Writeln("hello");                    // this is not tracked

doc.StartTrackRevisions("amorozov");
builder.Writeln("message from amorozov");    // this is marked as inserted by amorozov

doc.StartTrackRevisions("ddarkin");
builder.Writeln("comment from Denis");       // this is marked as inserted by ddarkin

doc.StartTrackRevisions("rk", DateTime.Now);
doc.RemoveAllChildren();                     // both paragraphs inserted above are marked as deleted

doc.StopTrackRevisions();

builder.Writeln("let's start it all over");  // this is not marked because tracking has been stopped.
doc.Save(MyDir + "18.5.docx");

Hello, thank you for answer.
You say, that when Document.TrackRevisions property is true changes are tracked, but i use my code above set TRUE, download Doc, then I try to make changes in MS Word and they are not marked by changes, i.e. tracking is not conducted. From your answer I did not quite understand what DocumentBuilder
is doing and whether he will help me. Judging by the code, as if he tracks changes that are made from the same code, and not by hands in MS Word?

@AlexBpm,

Please use latest version of Aspose.Words for .NET 18.5 and execute the following code example. Open the output document in MS Word and type some text. You will notice that MS Word track the changes. If it is not working at your end, please ZIP and attach your input Word document here for testing. We will investigate the issue and provide you more information on it.

Document doc = new Document(MyDir + "in.docx");
doc.TrackRevisions = true;
                 
doc.Save(MyDir + "18.5.docx"); 

Could you please share some more detail about your requirement? We will then provide you more information on it along with code.