4

Does anyone know whether it's possible to handle content changes or more precisely whether there's an event for that... one that would notify me if a document's content has been changed (ideally at what position/range etc)?

Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
Jörg Battermann
  • 4,044
  • 5
  • 42
  • 79
  • Well, there is the DocumentChange event which supposedly fires when a new document is created. I had a look at the Word 2k7 object model, and nothing akin to what your looking for. When you think about it, if their was one, it would fire all the time, so by definition, their isn't one, as the system would become unresponsive,due to the flood of events. Hope that helps. Bob. – scope_creep Oct 03 '09 at 15:25
  • Just checking in to see if the answer below addressed your question or you need further information. – Todd Main Jan 09 '10 at 22:09

2 Answers2

1

This is not possible anymore. In Office 2007 and below you could use smart tags and create a custom smart tag, which get called back into when content changes, but they were removed in Office 2010 :(

I think that a Timer is the only way to go, unfortunately you would have to make sure you did not kill performance of word if taking this approach..

Jake Ginnivan
  • 2,112
  • 16
  • 20
0

The event is "Application.WindowSelectionChange" that will notify of any content changes, but it doesn't notify of what changed like location/position - you'll have program in what you want to look for.

Todd Main
  • 28,951
  • 11
  • 82
  • 146
  • Is that not fired when a selection is made, bounded by a Range object. So unless the full document is selected that won't fire. – scope_creep Oct 06 '09 at 10:08
  • According to the docs, a Selection object represents A selection represents either a selected (or highlighted) area in the document, or it represents the insertion point if nothing in the document is selected. There can be only one Selection object per document window pane, and only one Selection object in the entire application can be active. – scope_creep Oct 06 '09 at 10:10
  • So that only fires when the selection changes, i.e. a different area is selected. – scope_creep Oct 06 '09 at 10:11
  • It fires when content changes; for example you type the letter "a". In this case, nothing is selected. Another example is if you select a paragraph with your mouse and make it all bold. Did you have a different scenario for content changes tracking? – Todd Main Oct 06 '09 at 14:02
  • It is not fired after typing a return key. But is fired when moving the cursor with arrow keys. – Fuhrmanator Nov 26 '14 at 18:12