Hi, I am writing an extension for Microsoft Word. I need to handle various words and shortcuts. For example, if the user types %BLA%, my program will change %BLA% to a value that I will define for it. Does anybody know how I can interact with MS Word's main window and retrieve and set text?
Posted on 2008-01-17 13:39:47 by XCHG
You have to interface with MS Word via it's API. You might start here...


Posted on 2008-01-17 20:24:00 by donkey
I'm afraid you'd have to learn COM programming (ugh!)
Posted on 2008-01-17 20:30:34 by vid
...or vbscripting :)
Posted on 2008-01-18 04:21:23 by f0dder
If you are looking for an MSWord host and you are willing to use OA32, then i have what you want (in an early stage).
In the OA32 distribution package I have added an Excel Host. Take a look at it to see what it is.


Posted on 2008-01-18 10:55:51 by Biterider
Lazy/hacky option C...

Use a global keyboard hook. (SetWindowsHookEx api)
-Check what app is currently active
-Check the pressed keys (keep a history/cache)

IF the app matches and the input matches, THEN send X number of backspaces (X being the length of the input to replace) and send your new input all as emulated keystrokes.

For instance, if someone types half of your keyword "%BL" then moves to another part of the document and types, then moves back and finish "AH%" the mechanism will fail. Or to be more precise, has the potential of failing or giving undesired results depending on how you code it.
Posted on 2008-02-11 13:09:13 by r22