form keypreview property

W

ward

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
 
W

Word Heretic

G'day "ward" <[email protected]>,

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:
 
W

ward

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
 
W

Word Heretic

G'day "ward" <[email protected]>,

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:
 

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