Form fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to limit a form field to 1 line only so when the enter key is
used to navigate round the form instead of the tab key another line is not
added? I have some fields that cannot be limited to a set sum of characters,
e.g names, and want to stop extra lines being added.
 
Put the field in a borderless table with fixed cell sizes.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
See “WD: How to Code ENTER Key to Move to Next Field in Form†at
http://support.microsoft.com?kbid=211219

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
I added the KB macros to my form and it did work, except that the formatting
of the field was not carried out (i.e. with format set to MM/dd/yy, input 5/4
and field showed 5/4 instead of 05/04/06) when using the enter key. I found
that by using the command SendKeys "{TAB}" the fields woud be formatted.
Also, did not have to check if was last field to go first field.

Here is the code.

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
' Go to the next form field if the current form field
SendKeys "{TAB}"
Else
' If the document is not protected for forms,
' insert a tab stop character.
Selection.TypeText Chr(13)
End If
End Sub
 

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

Back
Top