Aspose.Words for dotnet 25.4.0
Document revisions all have a DateTime set to 01/01/0001 00:00:00
Code :
Given the file Pierre2.docx has a few revisions ( track changes enabled )
var filename = @"C:\Users\Pierre\Documents\TrackTest\Pierre2.docx";
var doc = new Aspose.Words.Document(filename);
var revisions = doc.Revisions.ToList();
Thanks,
Pierre
@pnocera
It seems that you are encountering an issue where the DateTime
for all revisions in your document is set to 01/01/0001 00:00:00
. This typically indicates that the revisions were not properly tracked or that the document may not have been saved correctly after making changes.
To ensure that revisions are tracked correctly, you need to start tracking revisions with a specified author and a valid DateTime
. Here’s a basic example of how to do this:
var filename = @"C:\Users\Pierre\Documents\TrackTest\Pierre2.docx";
var doc = new Aspose.Words.Document(filename);
// Start tracking revisions with a specified author
doc.StartTrackRevisions("Your Name", DateTime.Now);
// Make some changes to the document
var builder = new DocumentBuilder(doc);
builder.Writeln("This is a new revision.");
// Stop tracking revisions
doc.StopTrackRevisions();
// Save the document
doc.Save(filename);
// Retrieve revisions
var revisions = doc.Revisions.ToList();
foreach (var revision in revisions)
{
Console.WriteLine($"Author: {revision.Author}, Date: {revision.DateTime}, Type: {revision.RevisionType}");
}
In this example, make sure to replace "Your Name"
with the actual name of the author making the revisions. After making changes and saving the document, the DateTime
for each revision should reflect the correct timestamp instead of the default value.
If you continue to see the DateTime
as 01/01/0001
, please ensure that the document is being modified and saved correctly, and that the revisions are being tracked as expected. If the issue persists, consider checking if the document is opened in a compatible version of Microsoft Word or if there are any restrictions on the document that might prevent tracking.
Feel free to reach out if you have any further questions or need additional assistance!
This is an existing document with existing revisions created in Word.
@pnocera Could you please attach the problematic document here for testing? We will check the issue and provide you more information.
@pnocera Thank you for additional information. As I can see revisions in your document does not have date specified. For example:
<w:ins w:id="0" w:author="Author">
<w:r>
<w:t>Pierre</w:t>
</w:r>
</w:ins>
Usually when revision is created by MS Word or by Aspose.Words date is specified like this:
<w:ins w:id="0" w:author="Alex Noskov" w:date="2025-05-05T19:32:00Z" w16du:dateUtc="2025-05-05T16:32:00Z">
<w:r>
<w:t>test</w:t>
</w:r>
</w:ins>
So it looks like the attached document has been created by some third-party tool that does not write full information about the revision into the document. Soo Aspose.Words does not have date for the revision to return.
That’s interesting. I have created it and did revisions with Word Professional Plus 2019, but you’re correct: if the information isn’t saved Aspose won’t invent it.
So I guess this is on Microsoft’s side…
Thanks for the quick reply,
Pierre
1 Like