VBA - totally disable Enter Key in Word Form? Keypreview in Word?

M

mokshadavid

FIRST, I've read the MS KB article on how to insert 4 macros into a word form
to make the enter key act as a tab, and that is not the answer I need. I
want to keep the conditional formatting in my data-entry table cells in my
Word form.

I see a lot of questions that ask this, but none that seem to ask/answer
this specific question. I want to totally disable the use of the Enter key
in my Word form, NOT try to use it as TAB.

I have created a form in Word 2002, which will be a template that users can
use to create a new form they can fill out. I am using EXACT row heights,
and the form is ready to go. However, I don't want the user to be able to
press the ENTER key in the form because it creates a new line, and I'm
working with NOVICE users, so I don't want ANYTHING to be confusing at all
(or the work won't get done!). So, I want to totally disable ENTER key use
via a Word function or VBA, so that nothing happens when they press it, maybe
just a Message-Box telling them that ENTER is disabled (they can navigate by
TAB and MOUSE).

Surely this is possible, especially in VBA code. Does Word have a
Keypreview property that I can change? Set KeyValue=0, or something? When
the doc opens, a Macro runs that disables the enter key by setting its value
to 0?

If you can help me with this, I'd appreciate it. A reading of many
discussion threads got me close to the answer, but doesn't have my
situational context.
 
M

mokshadavid

If you've read or are reading this, the current discussion involving this
topic is happening in my other thread post: "VBA - Word 2002 form | auto-SUM
function for bookmarked values". I will update this when a solution is found.

Check it out! - thanks, mokshadavid
 
M

mokshadavid

Here is what I put in my VBA code to disable the Enter Key in my Word 2002
form. It looks as if it could easily work just as well for any key, if you
know the character number.

Sub EnterKeyMacro()
If KeyAscii = 13 Then
cmdOk.Enabled = False
End If
End Sub

It works for me! I have a protected document template form that opens up
protected, and the user form that is generated from the template also still
opens up protected. The best part is that the ENTER key is disabled in
both.
 

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