none
How to Handle Word Document KeyPress or KeyDown Event? RRS feed

All replies

  • The Word object model does not expose these events, so there's nothing to be handled.

     

    You basically, can't "monitor" what the user is typing in Word, unless you're using VBA macros and assign every possible key combination to a KeyBinding.

     

    Wednesday, August 20, 2008 2:44 PM
    Moderator
  • Or you hook into the WndProc and handle all windows messages relating to keyboard. This is not good practice as there are a number of word windows and processes to monitor in different word states and there could be strange behaviour unexplainable by using this approach without considerable testing..

     

    You don't mention what you are trying to achieve and catch specifically but there are a number of options as Cindy states KeyBinding and my suggestion albeit a lot harder to manage.

     

    Regards

     

    Wednesday, August 20, 2008 10:02 PM
    Moderator
  • Thanks for your reply...

    I will explain you the scenario in detail.

    I am having a Word Add-In, I wanted to customize the Copy/Paste functionality for e.g. In Add-In I am having a Custom Data associated with an image. When image is copied and pasted I want to associate this Custom Data with the new image which is pasted in a Word Document.

    Thursday, August 21, 2008 5:13 AM
  • Hi Asif

     

    I'm sorry there hasn't been any more discussion on this. I was away for a couple of weeks and apparently no one else picked it up. Have you found a resolution to your issue?

     

     Asif Shaikh wrote:

    I am having a Word Add-In, I wanted to customize the Copy/Paste functionality for e.g. In Add-In I am having a Custom Data associated with an image. When image is copied and pasted I want to associate this Custom Data with the new image which is pasted in a Word Document.

     

    If not can you provide more detail about this? Word really doesn't provide a way to directly associate data with a particular object in the document. There might be ways to do something (such as bookmarking the object then giving a document Variable object a matching name), but we need to understand more about what kind of custom data, and under what circumstances this functionality might be needed.

    Sunday, September 14, 2008 11:50 AM
    Moderator