Peter Dongan
Peter Dongan

Reputation: 2308

Document.AcceptAllRevisions() in Word Interop did not work

I have the following code:

    rev2.AcceptAllRevisions();  
    var trackedChanges = rev2.Revisions;
    _logger.Info("Tracked change count: " + trackedChanges.Count);

This usually works as expected, but in one case it didn't. The logs show:

Tracked change count: 1

The document concerned has a tracked change saying

Formatted: Normal, no bullets or numbering.

Why did Document.AcceptAllRevisions() not clear that revision? How do I prevent it leaving revisions in place in future?

Upvotes: 0

Views: 35

Answers (1)

Peter Dongan
Peter Dongan

Reputation: 2308

Iterating through the revisions and accepting them individually worked in the case where the revision was not affected by AcceptAllRevisions()

i.e.:

    var trackedChanges = rev2.Revisions;

    for (var i = 1; i <= trackedChanges.Count; i++)
    {
        var trackedChange = trackedChanges[i];
        trackedChange.Accept();
    }

Upvotes: 0

Related Questions