none
Detecting if any change was made in a bookmark Range RRS feed

  • Question

  • Hi,

    I would like to detect if any change has been made inside a bookmark range.

    I have tried comparing the WordOpenXML against each other, however there's always small changes to the rsid values irrepective of any changes made to the actual content

    ie w:rsidP & w:rsidRDefault

    Apparently such values are dynamically generated behind the scenes and used for version control.

    The closest I can to detecting if a change was made is counting how many elements are in the range

    ie bookmark.range.End - bookmark.range.Start

    This covers most scenarios but I would still like to detect pure formatting changes and the like. Any suggestions?

    Thursday, April 24, 2014 6:03 AM

Answers

  • Hi Nathan

    Which version of Word?

    Are you interested in just the text, or also the formatting?

    One possibility that occurs to me would be to use a content control instead of (or parallel to) a bookmark. Link the content control to a node in a Custom XML Part and you can use the events for the Custom XML Part to trap whenever the node's value changes (whenever the user changes the text in the content control).

    It's also possible to "filter out" information from the Word Open XML that you don't need to "see". For example, you can get all the <w:t> elements and ignore everything else.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, April 24, 2014 4:28 PM
    Moderator

All replies

  • Have you thought of using Track Changes? You could then test for any revisions in the bookmarked range. The only thing it won't pick up is if someone actually redefines the bookmarked range.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Thursday, April 24, 2014 9:40 AM
  • Hi Nathan

    Which version of Word?

    Are you interested in just the text, or also the formatting?

    One possibility that occurs to me would be to use a content control instead of (or parallel to) a bookmark. Link the content control to a node in a Custom XML Part and you can use the events for the Custom XML Part to trap whenever the node's value changes (whenever the user changes the text in the content control).

    It's also possible to "filter out" information from the Word Open XML that you don't need to "see". For example, you can get all the <w:t> elements and ignore everything else.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, April 24, 2014 4:28 PM
    Moderator