none
Record only my changes on word document and undo those. RRS feed

  • Question

  • hi

    I'm writing add-in for word to change word display text property(change font/color/bgcolor add some hyper links  for predefined texts). I'm doing these changes during just before display of word document.

    When user closes the document I want remove the changes which I made (user also would have made some changes, that I do not want remove)

    I tried with while(doc.undo()); that removes all the changes :(

    1) is it possible to undo only my changes

    2) Record my changes and undo only those changes.


    Balamurali C

    Wednesday, June 17, 2015 6:03 AM

Answers

  • As I said in my previous post, you would need to use 'Track Changes' to record at least your changes. You could then loop through the .Revisions collection and reject any changes attributed to you. Without using 'Track Changes', there is no way to differentiate your changes from anyone else's; indeed you can't even identify what's been changed unless you keep a copy of the original for comparison purposes.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Wednesday, June 17, 2015 8:46 AM

All replies

  • If you use 'track changes', a macro could be used to reject any changes you've made (provided someone hasn't accepted them beforehand).

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Wednesday, June 17, 2015 6:45 AM
  • Hi Paul,

     I'm doing in c# addin.

     load()

       {

      word.document doc = getCurrntActiveDoc();

       doc.Content.hyperlinks.Add(etc...);

       doDOMoreChangesInDoc(doc);

     }

      unLoad()

      {    

       word.document doc = getCurrntActiveDoc();

       while(doc.undo()); //I don't want save my changes which I did during 'load()' 

                                // if user made some changes (after my changes), I want save those changes, during unLoad

     }




    Balamurali C



    • Edited by techpach Wednesday, June 17, 2015 7:03 AM
    Wednesday, June 17, 2015 7:01 AM
  • As I said in my previous post, you would need to use 'Track Changes' to record at least your changes. You could then loop through the .Revisions collection and reject any changes attributed to you. Without using 'Track Changes', there is no way to differentiate your changes from anyone else's; indeed you can't even identify what's been changed unless you keep a copy of the original for comparison purposes.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Wednesday, June 17, 2015 8:46 AM
  • Hi Balamurali

    I agree with Paul.

    While newer Word versions do provide a way for you to create an "Undo" block of actions, all this does is group your actions into one entry. But there's no way to go back and undo only a certain entry - everything must be undone that was performed at a later point. Track Changes (Revisions in the Word object model) is the only technology Word provides that could help you with this.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, June 17, 2015 7:12 PM
    Moderator