问题描述
我正在尝试编写一些在您键入Word时执行的代码.
I'm trying to write some code which executes as you type in Word.
我应该观察哪些事件来捕捉单个单词或字符?理想情况下,我宁愿不要通过某些dll调用来观察击键.我假设Word对象模型将公开本地VBA事件的某些类,但是只有两个事件对象:
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
没有任何发生在我身上的事件. (Document_Change
事件似乎没有满足我的要求
don't have any events that leap out at me. (Document_Change
event doesn't seem to do what I want)
当文档的文本内容更改时,是否有本机执行代码的方法?
推荐答案
Word提供 no 事件以捕获用户的键入.
Word provides no events for capturing the user's typing.
剩下的:
- Windows API级别的
-
键盘挂钩".
"keyboard hooks" at the Windows API level.
或为每个可能的组合键分配一个VBA宏(一个KeyBinding
).
Or assigning a VBA macro to each and every possible key combination(a KeyBinding
).
这篇关于我可以使用哪些事件来监视在Word中键入的用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!