key behavior

M

micfly

How do I get the return key to act like a tab key in a Word 2002 doc?
Or second option, disable the return key? Thanks
 
M

micfly

Thanks for helping. I had seen this link but was having a hard time
implementing it (beginner).
I'm not sure what to do with the macros and what to do once I make a
template or how to make the template. Can you elaborate a little for a
bigger?
Thanks!
 
D

Doug Robbins - Word MVP

See the article "What do I do with macros sent to me by other newsgroup
readers to help me out?" at:
http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm


--
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, originally posted via msnews.microsoft.com
 
M

micfly

Thanks, that was very helpful. Still at little over my head at this point
but good reference. I would still think there would be an easier way to
disable the enter key, though?
 
M

micfly

I have been unable to get the macros to work. What about?:

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

This doesn't seem to work either. Can someone elaborate a little please?
Thanks
 
G

Graham Mayor

Why would you think that? There are four macros on the linked page all of
which are required in the form template and the template must be left
unprotected. The auto macros set the protection having fulfileld their
roles.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

micfly

OK, so I'm trying to get these macros to work as per
http://support.microsoft.com/kb/211219.

I'm still having trouble getting this to work. I have several text form
fields named text5, text6, text7 and so forth.
I named them in the bookmark section of the text fields properties ( I guess
that is how I am suppose to do it?). In the SubEnterKeyMacro I replaced
myformfield with text5 like so:

Sub EnterKeyMacro()
' Check whether the document is protected for forms
' and whether the protection is active.
If ActiveDocument.ProtectionType = wdAllowOnlyFormFields And _
Selection.Sections(1).ProtectedForForms = True Then
' Retrieve the bookmark of the current selection.
' This is equivalent to the name of the form field.
text5 = Selection.Bookmarks(1).Name
' Go to the next form field if the current form field
' is not the last one in the document.
If ActiveDocument.FormFields(text5).Name <> _
ActiveDocument.FormFields(ActiveDocument.FormFields.Count) _
.Name Then
ActiveDocument.FormFields(text5).Next.Select
Else
' If the current form field is the last one,
' go to the first form field in the document.
ActiveDocument.FormFields(1).Select
End If
Else
' If the document is not protected for forms,
' insert a tab stop character.
Selection.TypeText Chr(13)
End If
End Sub

It seems to want to work, as in, I can enter data in the first field (text5)
and press enter and it moves to the next text field.
From there (text6) when enter is pressed I get an error: The requested
member of the collection does not exist.
I know I need to add additional code for my remaining text fields but do not
know how. Also, after pressing enter on the first text field it won't let me
go back to that field, as in, clicking in the text box it immediately moves
the cursor to the next text box?

Can someone help? thanks
 
G

Graham Mayor

Why did you replace myformfield with text5? Use the macro as provided!

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
..
 
M

micfly

Hmmm, OK I put myformfield back in the code. I'm still getting the error
"The requested member of the collection does not exist." when I hit Enter
after the first text field. I can tab and use the up/down arrows fine and
use Enter on the first text field but after that Enter sets the error on any
other text field.
What's wrong?
 
G

Graham Mayor

You need to copy all of the macros from the page, without altering any of
them to your form. (not to the normal template)
Do not lock the form
Save the form as a template (macro enabled template in Word 2007) and close
it.
When you create a new document from the form, the autonew macro in the
template changes the behaviour of the enter key and locks the form.
When you need to re-open the document you have provided the template is
still available, the enter key will work in exactly the same way.
The macros are not associated with the fields, but with the behaviour of the
enter key and work as supplied. All you have to do is copy and paste.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

micfly

OK, I finally got it. Had to delete my doc and template and just start
over...thanks for the help!
 
G

Graham Mayor

You are welcome :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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