Change event in Microsoft.Office.Interop.Word

Whether an event occurs in the above namespace when any changes occur or documents are edited, for example, text input occurs

I tried

Microsoft.Office.Interop.Word.ApplicationEvents4_WindowSelectionChangeEventHandler
&
Microsoft.Office.Interop.Word.ApplicationEvents4_EPostageInsertEventHandler

But I cannot trigger an event whenever I insert text into an active word document.

+4
source share
2 answers

Unfortunately, the Word object model does not provide any keystroke events,

Word Event List - Document Events

You can try global keyboard grabbing to achieve what you are looking for through the Win32 API.

+1
source

You can find a rather old, but still very informative page on the MVPS Word site about using Word Events in VBA programming ( http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm ). Note the disclaimer at the end of the page that using certain events can lead to a performance hit in Word; I also remember other pages expressing this warning about "catch a text type event."

In fact, I have been developing Word solutions since 1994 and have rarely discovered the need to catch a type event. I would rather be afraid to mix with user input at this level and look for an alternative approach.

0
source

Source: https://habr.com/ru/post/1403141/


All Articles