Replace the macro in the KnowledgeBase Article with:
Sub EnterKeyMacro()
' Check whether the document is protected for forms
If ActiveDocument.ProtectionType <> wdAllowOnlyFormFields
'The document is not protected for forms,
' insert a carriage return.
Selection.TypeText Chr(13)
End If
End Sub

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Thanks, yes, I've read that article, but when a user presses enter to
> "TAB"
[quoted text clipped - 22 lines]
>> Email cannot be acknowledged; please post all follow-ups to the newsgroup
>> so all may benefit.
mokshadavid - 29 Jun 2008 03:03 GMT
Thanks Doug, your comment got me focused on that EnterKey() macro, and I
whittled things down from there.
Ok, would someone please help me test this? I think this is the solution
I've been looking for, but before I ~announce~ it, I would like to know if it
works.
My goal: To disable the enter key in a Microsoft Word 2002 table form so
that nothing happens when the user hits the enter key, and they have to
navigate by mouse and TAB key. This is so the form does not get changed.
This is also to retain numerical formatting in my cells that calculate on
field exit. I didn't not want the Enter key to act like a TAB.
Here is what I put in my VBA code:
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.
The only downside I see is that I would have to disable the MACRO to update
the template form (in some ways), because the ENTER key is disabled for the
form, original template and copies.
Thanks - mokshadavid
> Replace the macro in the KnowledgeBase Article with:
>
[quoted text clipped - 6 lines]
> End If
> End Sub
mokshadavid - 29 Jun 2008 05:34 GMT
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.
p.s. I don't know why it works. I have no idea what cmdOk.Enabled=False
means, I found it on some forum, and it works better than anything else I've
seen.