What events can I use to monitor users typing in Word?

99封情书 提交于 2019-12-31 07:09:06

问题


I'm trying to write some code which executes as you type in Word.

Which events should I observe to catch individual words or characters? Ideally I'd rather not observe keystrokes through some dll calls. I assumed the Word object model would expose some classes with native VBA events, but the only two event objects:

Word.Document
Word.Application

don't have any events that leap out at me. (Document_Change event doesn't seem to do what I want)

Is there a native way of executing a code when the text content of the document changes?


回答1:


Word provides no events for capturing the user's typing.

That leaves:

  • "keyboard hooks" at the Windows API level.

  • Or assigning a VBA macro to each and every possible key combination (a KeyBinding).



来源:https://stackoverflow.com/questions/57338375/what-events-can-i-use-to-monitor-users-typing-in-word

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!