text-events in MS-Word ?

T

Tamir

Hi,
Is there an event that is raised when the text in a word doc is
changes? or when a new word was created?
If no, is there some other way to react to such changes?

Best regads.
 
C

Cindy M.

Hi =?Utf-8?B?VGFtaXI=?=,
Is there an event that is raised when the text in a word doc is
changes? or when a new word was created?
If no, is there some other way to react to such changes?
No. And not really.

IF your code is all in a Word VBA project, then you *could*
assign each key combination to a macro and capture the "key
presses" like that. It's the only possibility Word provides.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17
2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
T

Tamir

Im not sure i understand how to do that can you (pleas) be more specific?

Thanks.
 
C

Cindy M.

Hi =?Utf-8?B?VGFtaXI=?=,
Im not sure i understand how to do that can you (pleas) be more specific?
Open a Word document. Start the macro recorder (Tools/Macro/Record macro).
Enter a name and click the "keyboard shortcut" button. In the "Press
key..." box enter a keyboard shortcut (Alt+N) for example. Record the
macro.

When you're finished, you should be able to replay the macro at any time by
pressing the keyboard shortcut you specified.

You can't use this dialog box to assign VBA procedures to all possible key
combinations, but it demonstrates the principle. In the Word object model
the KeyBindings collection is responsible for this functionality and it
*can* make assignments to everything except key combinations that belong to
Windows.

The key points are:

1. This can only be done with "macros" (public sub procedures) stored in a
Word VBA module.

2. You need to use KeyBindings.Add to make the assignments. This should be
a one-off proposition, as the assignments will be stored in a Word file.

3. You MUST specify the CustomizationContext for the application when
making the assignments. (Most likely in a template that will be used to
generate the type of document you're doing this for so that the user can
otherwise work normally with Word.)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
T

Tamir

Hi Ciny and thanks,
as I understand the macros will be fired only when a combination of key
strokes will be pressed ??? thus, what about backspace, dellete and the like
???
Will it be possible for me to call (invoke) these VBA methods from an MFC
project ???

However thanks it is a considerable solution.
 
C

Cindy M.

Hi =?Utf-8?B?VGFtaXI=?=,
as I understand the macros will be fired only when a combination of key
strokes will be pressed ??? thus, what about backspace, dellete and the like
???
Most of these can be assigned using KeyBindings, but not through the UI
Will it be possible for me to call (invoke) these VBA methods from an MFC
project ???
You can certainly call the macros from an outside project, using the
Application.Run method. But I'm not sure what you hope to accomplish with
doing that.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
T

Tamir

Hi Cindy,
thanks for your help.
But as it seems to me (since I work in C++) it will be easier to write a
dedicated key-logger for ms-word and fire events from there.
Do you agree with me ?

Best regards.
 
C

Cindy M.

Hi =?Utf-8?B?VGFtaXI=?=,
But as it seems to me (since I work in C++) it will be easier to write a
dedicated key-logger for ms-word and fire events from there.
Do you agree with me ?
If you can get it to work. I'm not a C++ person, but I've worked with other
C++ programmers over the years, trying to find a solution, and they've been
thoroughly frustrated. Word doesn't expose the key presses the same way
other apps do...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top