Word2010 - reject revisions in comment.scope RRS feed

  • Question

  • Hi

    I'm trying to reject all revisions that exist in the scope of a comment..
    My scenario is this:
    a user makes a selection in a document, with the intention of wanting to reject ALL revisions made to the document, in that selection..

    pressing a button triggers my code that is supposed to do the following:

     - Iterate all the revisions in the selection
     - Make a comment with the revisions range as scope, saying "a revision was rejected here" (or whatever)
     - Reject the revision

    what I would like to end out with, is a number of comments, pointing to the places in the document, where the revisions were rejected..

    I have tried quite a few ways to make this work, and none seem to do the trick, and crashes my application with a "This command is not available" exception..
    I have noted, that if my selection only contains 1 revision, it will work just fine..

    here are some code snippets

    Word.Range orgSelection = appWord.Selection.Range;
    foreach (Word.Revision objRevision in orgSelection.Revisions)
                        int commentStart = objRevision.Range.Start > orgSelection.Start ? objRevision.Range.Start : orgSelection.Start;
                        int commentEnd = objRevision.Range.End > orgSelection.End ? orgSelection.End : objRevision.Range.End;
                        Word.Range commentRange = orgSelection.Document.Range(commentStart, commentEnd);
                        comments.Add(appWord.ActiveDocument.Comments.Add(commentRange, "test comment"));
    foreach (Word.Comment objComment in comments)
                        catch (Exception ex)
                            var error = ex;

    I'm quite perplexed, since this seems to be doable manually in Word..

    any help will be apreciated


    Monday, February 25, 2013 1:18 PM

All replies

  • have you tried record macro

    you can upload your programm and sample docuemnt

    with regards, Yuri

    Wednesday, February 27, 2013 9:50 AM