Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2005

Tip: Looking for answers? Try searching our database.

How do I prevent a line break in a form field?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
numbercruncher88 - 30 Oct 2005 17:40 GMT
How do I prevent a form user from entering a "return" character - it is
dropping the form line down and messes everything up.  Also , if you limit
the form field to 10 text characters, can you size the form to 10 characters?
So that way the form is locked and doesn't change as the user enters the
information in the blank lines?
Tony Jollans - 30 Oct 2005 20:39 GMT
You can reassign the Enter key so that it does nothing ..

Sub DummyReturnKey()
End Sub

Sub ToggleReturnKey()
   CustomizationContext = ActiveDocument
   Set Key = FindKey(BuildKeyCode(wdKeyReturn))
   If Key.KeyCategory = wdKeyCategoryNil Then
       KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), _
                       KeyCategory:=wdKeyCategoryCommand, _
                       Command:="DummyReturnKey"
   Else
       Key.Clear
   End If
End Sub

The Toggle routine will toggle the effect of the return key - either normal
or assigned to the empty sub above. Use at appropriate points (or extract
appropriate code from it and use that at appropriate points) such as
document_open and document_close.

--
Enjoy,
Tony

> How do I prevent a form user from entering a "return" character - it is
> dropping the form line down and messes everything up.  Also , if you limit
> the form field to 10 text characters, can you size the form to 10 characters?
>  So that way the form is locked and doesn't change as the user enters the
> information in the blank lines?
Stefan Blom - 31 Oct 2005 12:01 GMT
See the following KB article:

How to code the ENTER key to move between form fields in a protected
form in Word
http://support.microsoft.com/default.aspx?scid=kb;en-us;211219

Signature

Stefan Blom
Microsoft Word MVP

> How do I prevent a form user from entering a "return" character - it
> is
[quoted text clipped - 5 lines]
> enters the
> information in the blank lines?
Stefan Blom - 31 Oct 2005 12:04 GMT
And for the second question, place the form field in a table cell with
fixed dimensions.

Signature

Stefan Blom
Microsoft Word MVP

> See the following KB article:
>
[quoted text clipped - 11 lines]
> > enters the
> > information in the blank lines?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.