No multi-line field

  • Thread starter Thread starter jsnlfromthenl
  • Start date Start date
J

jsnlfromthenl

I a form is to possible to NOT allow multi-line input?

As it is, a person CAN hit the return-key, even if you've specified a
limited number of characters.
If the return-key is hit, a 2nd line will appear, but it's not visible
(if the row has a exact height, which is the case here).

Regards,
JeLa
 
Hi JeLa,

You could add a macro to the document to either:
.. test the formfield for the presence of a carriage return and, if found, delete it; or
.. make the enter key take you to the next formfield (as happens with the tab).

The following macro will remove the carriage returns from all data entry formfields in the document. You could call it from each
formfield as an on-exit macro, or from just one formfield (eg the last formfield to be filled in). Alternatively, you could
intercept the document save/print routines.
Sub FFClean_Up()
Dim FrmFld FormField
For Each FrmFld In ActiveDocument.FormFields
If FrmFld.Type = wdFieldFormTextInput Then FrmFld.Result = Replace(FrmFld.Result, vbCr, "")
Next
End Sub
You could also modify the code so that it removes the enter keys from nominated formfields only.

To see how to make the enter key behave like the tab key, go to:
http://support.microsoft.com/default.aspx/kb/211219

Cheers
 
Thanks, but this is difficult stuff for me. I have to confess that my
macro-skills are zero.
I did try it, thogh, but it didn't work.
Then I checked the macro and got an compilation error in the line 'Dim
FrmFld FormField'.
It said it expected an end of command (or something like that) instead
of 'FormField'.

Then I tried the macro suggested on the support-page you gave me.
I got the error saying that this was a key that couldn't be modified
(or something like that)

Jenny

Hi JeLa,

You could add a macro to the document to either:
. test the formfield for the presence of a carriage return and, if found, delete it; or
. make the enter key take you to the next formfield (as happens with the tab).

The following macro will remove the carriage returns from all data entry formfields in the document. You could call it from each
formfield as an on-exit macro, or from just one formfield (eg the last formfield to be filled in). Alternatively, you could
intercept the document save/print routines.
Sub FFClean_Up()
Dim FrmFld FormField
For Each FrmFld In ActiveDocument.FormFields
If FrmFld.Type = wdFieldFormTextInput Then FrmFld.Result = Replace(FrmFld.Result, vbCr, "")
Next
End Sub
You could also modify the code so that it removes the enter keys from nominated formfields only.

To see how to make the enter key behave like the tab key, go to:http://support.microsoft.com/default.aspx/kb/211219

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

I a form is to possible to NOT allow multi-line input?
As it is, a person CAN hit the return-key, even if you've specified a
limited number of characters.
If the return-key is hit, a 2nd line will appear, but it's not visible
(if the row has a exact height, which is the case here).
Regards,
JeLa
 
Hi Jenny,
Then I checked the macro and got an compilation error in the line 'Dim
FrmFld FormField'.

Dim FrmFld as FormField

don't know about the rest of the code.



--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
Hi Jenny,

Sorry about the error in the code I posted. That line should have read 'Dim FrmFld As FormField'.

As for the code on the Microsoft site, it should work with Word 2000 and later, but you'll need to follow the instructions
carefully. If you're using Word '97, there's a link there to a page with code for that version too.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Thanks, but this is difficult stuff for me. I have to confess that my
macro-skills are zero.
I did try it, thogh, but it didn't work.
Then I checked the macro and got an compilation error in the line 'Dim
FrmFld FormField'.
It said it expected an end of command (or something like that) instead
of 'FormField'.

Then I tried the macro suggested on the support-page you gave me.
I got the error saying that this was a key that couldn't be modified
(or something like that)

Jenny

Hi JeLa,

You could add a macro to the document to either:
. test the formfield for the presence of a carriage return and, if found, delete it; or
. make the enter key take you to the next formfield (as happens with the tab).

The following macro will remove the carriage returns from all data entry formfields in the document. You could call it from each
formfield as an on-exit macro, or from just one formfield (eg the last formfield to be filled in). Alternatively, you could
intercept the document save/print routines.
Sub FFClean_Up()
Dim FrmFld FormField
For Each FrmFld In ActiveDocument.FormFields
If FrmFld.Type = wdFieldFormTextInput Then FrmFld.Result = Replace(FrmFld.Result, vbCr, "")
Next
End Sub
You could also modify the code so that it removes the enter keys from nominated formfields only.

To see how to make the enter key behave like the tab key, go to:http://support.microsoft.com/default.aspx/kb/211219

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

I a form is to possible to NOT allow multi-line input?
As it is, a person CAN hit the return-key, even if you've specified a
limited number of characters.
If the return-key is hit, a 2nd line will appear, but it's not visible
(if the row has a exact height, which is the case here).
Regards,
JeLa
 

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