Hello,

I would like to trap the _keydown even of a Word VBA form.
This only works if there are no other controls on the
form, because otherwise the focussed control's event is
fired (and not the form's event).

In VB (and Access VBA) a form has .KeyPreview property,
which allows to trap keypresses. But in Word VBA the
property is not there.

How can i trap a keypress on a form with multiple controls?

Ward

Re: form keypreview property by Word

Word
Sat Feb 21 18:28:20 CST 2004

G'day "ward" <anonymous@discussions.microsoft.com>,

from the help system:

To respond to the physical state of the keyboard, or to handle
keystrokes not recognized by the KeyPress event, such as function
keys, navigation keys, and any combinations of these with keyboard
modifiers (ALT, SHIFT, or CTRL), use the KeyDown and KeyUp event
procedures.

The sequence of keyboard-related events is:

KeyDown


KeyPress


KeyUp


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


ward reckoned:

>Hello,
>
>I would like to trap the _keydown even of a Word VBA form.
>This only works if there are no other controls on the
>form, because otherwise the focussed control's event is
>fired (and not the form's event).
>
>In VB (and Access VBA) a form has .KeyPreview property,
>which allows to trap keypresses. But in Word VBA the
>property is not there.
>
>How can i trap a keypress on a form with multiple controls?
>
>Ward


Re: form keypreview property by ward

ward
Mon Feb 23 01:38:05 CST 2004

That's the problem. The events are not coming through,
because the form object doesn't have the focus. Instead,
the events are fired for the object (command bar, text
box, etc) which at that moment has the focus.

I'm looking for a global way to trap a pressed key.

Ward


>-----Original Message-----
>G'day "ward" <anonymous@discussions.microsoft.com>,
>
>from the help system:
>
>To respond to the physical state of the keyboard, or to
handle
>keystrokes not recognized by the KeyPress event, such as
function
>keys, navigation keys, and any combinations of these with
keyboard
>modifiers (ALT, SHIFT, or CTRL), use the KeyDown and
KeyUp event
>procedures.
>
>The sequence of keyboard-related events is:
>
>KeyDown
>
>
>KeyPress
>
>
>KeyUp
>
>
>Steve Hudson - Word Heretic


Re: form keypreview property by Word

Word
Mon Feb 23 17:52:39 CST 2004

G'day "ward" <anonymous@discussions.microsoft.com>,

Ahhhh. Can you get away with just binding it to a function. You know,
set a shortcut...


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


ward reckoned:

>That's the problem. The events are not coming through,
>because the form object doesn't have the focus. Instead,
>the events are fired for the object (command bar, text
>box, etc) which at that moment has the focus.
>
>I'm looking for a global way to trap a pressed key.
>
>Ward
>
>
>>-----Original Message-----
>>G'day "ward" <anonymous@discussions.microsoft.com>,
>>
>>from the help system:
>>
>>To respond to the physical state of the keyboard, or to
>handle
>>keystrokes not recognized by the KeyPress event, such as
>function
>>keys, navigation keys, and any combinations of these with
>keyboard
>>modifiers (ALT, SHIFT, or CTRL), use the KeyDown and
>KeyUp event
>>procedures.
>>
>>The sequence of keyboard-related events is:
>>
>>KeyDown
>>
>>
>>KeyPress
>>
>>
>>KeyUp
>>
>>
>>Steve Hudson - Word Heretic