Revisions

I see that a list of revisions can be retrieved through Document.Revisions.

It there anyway to get the revisions on a Run from the Run? i.e. as I’m traversing the object model find if the object I’m on has revisions?

Also is there a way to reverse an accept/ reject action? What I mean after a revision is accepted to return it to a pending state?

@robschenkel

Thanks for your inquiry. You can check whether a run has revisions. Please check IsDeleteRevision, IsFormatRevision and IsInsertRevision property of Run object.

I think it is not possible, even we cannot achieve this in MS Word.

Hello @tilal.ahmad,

I understand that there are IsDeleteRevision, IsFormatRevision, and IsInsertRevision on each run… however I’m wondering how to tie this back the the specific run.

The reason is to get the differences between the original and revised when it is a format revision.

Thanks.

@robschenkel

Thanks for sharing the additional information. We are looking into it and will guide you accordingly.

@robschenkel

Thanks for your patience. We can get revision details and related run as following. However, for your requirements we will appreciate it if you please share your sample input and output documents as zip file along with some more details. We will look into it and will guide you accordingly.

Document doc = new Document("RevisionTest.docx");
Run rrun = null;
foreach (Run run in doc.GetChildNodes(NodeType.Run, true))
{
    if (run.IsDeleteRevision || run.IsInsertRevision || run.IsFormatRevision)
    {
        rrun = run;

        foreach (Revision rev in doc.Revisions)
        {
            if (rev.ParentNode == rrun)
                Console.WriteLine("Revision type: " + rev.RevisionType + " Text: " + rev.ParentNode.ToString(SaveFormat.Text));

        }
    }
}