none
How to detect changes affected by track change "ON"? RRS feed

  • Question

  • Hello,

    In am creating a Word add-in using VSTO 2010 in c#. which is template based add-in. I want to know how to detect changes on any item like table, text by track changes "ON". How to track the changes to an Active Word Document like deletion of table or text and insertion of text or images and their deletion.... or any short of change. it must be able to track in my button call.

    Thanks,

    Anil

    Friday, January 31, 2014 2:03 PM

All replies

  • Hello Anil,

    Unfortunately the Word Object Model doesn't provide any events for tracking changes in the document. Please read more about this in the following articles:

    Word Object Model Overview

    Understanding the Word Object Model from a .NET Developer's Perspective

    Automating Applications Using the Office Object Model

    Friday, January 31, 2014 2:25 PM
  • Supplementing Eugene's reply...

    What is the purpose of wanting to "track" changes the user makes in a document as they are made?

    As Eugene says, there are no events triggered when the user types in a document, at best, you'd have to use Windows API keyboard hooks to capture those kinds of actions if you're coding using a language other than VBA running in-process in the Word application.


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, January 31, 2014 6:40 PM
    Moderator
  • hello Cindy Meister,

    the purpose of wanting to track changes the user makes in a document as they are made is user set bit value in our template table like 1. and if the track changes is on and then he makes the change the text 1 to 0 then application read 10 etc a wrong value but user gives correct value 0.

    I don't want any event trigger for track change but i want to track value before and after change in my button click.

    ------------------

    Thanks,

    Anil

    Monday, February 3, 2014 6:07 AM
  • hello Eugene Astafiev,

    I don't want any event trigger for track change but i want to track value before and after change in my button click.

    the purpose of wanting to track changes the user makes in a document as they are made is user set bit value in our template table like 1. and if the track changes is on and then he makes the change the text 1 to 0 then application read 10 etc a wrong value but user gives correct value 0.

    ------------------

    Thanks,

    Anil

    Monday, February 3, 2014 6:09 AM
  • Hi Anil

    It's not clear how your application functions that you'd have the problem:

    << change the text 1 to 0 then application read 10 etc a wrong value but user gives correct value 0>>

    but the Word object model has a Revions collection that will let you loop the Revisions in the document. And it has a ShowRevisions method that can turn the display of Revsions on/off, which will affect what the Range.Text property returns. I imagine either or both of these in combination should allow you to solve your issue...


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, February 3, 2014 9:20 AM
    Moderator
  • hello Cindy Meister,

    My application is table based and we read cell text. a cell have text "1" and then track changes on another user delete the text "1" then text show with cross line and then user write "0".

    The problem is reading cell text. because it return both "1" and "0". but actual value is only "0".

    Then my question is how we read undeleted text.

     thanks,

    Anil

    • Edited by Anil1234 Friday, February 7, 2014 6:26 AM name
    Friday, February 7, 2014 6:26 AM
  • hello Eugene Astafiev,

    My application is table based and we read cell text. a cell have text "1" and then track changes on another user delete the text "1" then text show with cross line and then user write "0".

    The problem is reading cell text. because it return both "1" and "0". but actual value is only "0".

    Then my question is how we read undeleted text.

     thanks,

    Anil

    Friday, February 7, 2014 6:28 AM
  • As I said, look at the ShowRevisions method of the object model. It's possible to tell Word what to show: Final with markup, Final without markup, Original with markup, Original without markup. Do some testing to find the setting that works for you...

    Cindy Meister, VSTO/Word MVP, my blog

    Friday, February 7, 2014 9:02 AM
    Moderator