Word2003 Form-Textbox fixed to 3 lines, not by character count?

A

Andrea

OK, here is my question....is there code I can use that allows me to type
text up to 3 lines versus limiting how much I type on 3 lines by character
count.

The file is a Word 2003 form/ template.

I have a textbox that has the following properties and it has to be
multiline (3 lines):
AutoSize=False
MaxLength=200
Height=39
Width=282.75
MulitLine=True

Problem: I want to allow people who are doing data entry to type up to 3
lines of text. The character count changes based on the sentences and how
many space bars they use....so my current solution of 200 characters is *not*
working because I do not know how many spacebars and periods they are going
to use so text is getting cut off and running onto a 4th line that is not
showing.

Recommendations????

Any help is appreciated!
Andrea :)
 
A

Anne Troy

Andrea: We usually use a table cell that is set to EXACTLY X" high. Then, no
matter how much they type, you can only see what you intended. This won't be
good if you're processing the data afterward, tho.
************
Anne Troy
www.OfficeArticles.com
 
A

Andrea

Hi Anne, thank you for the suggestion, it is a very creative work around. :)

I am still looking for a 'fixed' solution because what if they do type over,
then when they go to print they are going to be upset that not all of their
text did not print..... I tried a similar solution to what you recomemnded
yesterday and that was their latest complaint.

Thanks again...
Andrea
 
A

Anne Troy

Sorry, Andrea. The other answer is code, which I don't do personally.
However, even with code, unless the font is fixed-pitch, I don't see this
being easy to "force" to end at "x", you know?

My apologies... I've just realized you're talking about a textbox, and not
a text form field. Using a textbox smack-dab in the middle of a document is
not a good idea anyway. Perhaps you could tell us what kind of template
you're creating, and why you're using a textbox instead of form fields (see
http://www.officearticles.com/word/create_a_fill-in_form_in_microsoft_word.htm),
maybe we can be more helpful.
************
Anne Troy
www.OfficeArticles.com
 
J

Jay Freedman

OK, here is my question....is there code I can use that allows me to type
text up to 3 lines versus limiting how much I type on 3 lines by character
count.

The file is a Word 2003 form/ template.

I have a textbox that has the following properties and it has to be
multiline (3 lines):
AutoSize=False
MaxLength=200
Height=39
Width=282.75
MulitLine=True

Problem: I want to allow people who are doing data entry to type up to 3
lines of text. The character count changes based on the sentences and how
many space bars they use....so my current solution of 200 characters is *not*
working because I do not know how many spacebars and periods they are going
to use so text is getting cut off and running onto a 4th line that is not
showing.

Recommendations????

Any help is appreciated!
Andrea :)

Forget about the MaxLength -- as you already know, it's useless.

Instead, include this event procedure (change the default name
"TextBox1" to the name of your textbox throughout):

Private Sub TextBox1_Change()
With TextBox1
If .LineCount > 3 Then
.Text = Left(.Text, Len(.Text) - 1)
MsgBox "No more text, please!"
End If
End With
End Sub

This procedure runs on every keystroke that's typed in the textbox. As
long as the line count is 3 or less, it just exits. If the typed
character would cause a fourth line, the body of the If statement
"eats" the character.

The MsgBox is optional -- if you leave it out, the user just can't
type anything past the end of the third line (actually, they can type
lots of spaces there, but they won't appear).
 
J

Jay Freedman

Jay said:
Forget about the MaxLength -- as you already know, it's useless.

Instead, include this event procedure (change the default name
"TextBox1" to the name of your textbox throughout):

Private Sub TextBox1_Change()
With TextBox1
If .LineCount > 3 Then
.Text = Left(.Text, Len(.Text) - 1)
MsgBox "No more text, please!"
End If
End With
End Sub

This procedure runs on every keystroke that's typed in the textbox. As
long as the line count is 3 or less, it just exits. If the typed
character would cause a fourth line, the body of the If statement
"eats" the character.

The MsgBox is optional -- if you leave it out, the user just can't
type anything past the end of the third line (actually, they can type
lots of spaces there, but they won't appear).

I realized after I posted that code that it doesn't properly handle what
happens if the user pastes text into the box. If the pasted text would make
the contents longer than 3 lines plus 1 character, only the last character
would be removed and the contents would still be more than 3 lines.

This version fixes that:

Private Sub TextBox1_Change()
With TextBox1
Do While .LineCount > 3
.Text = Left(.Text, Len(.Text) - 1)
Loop
End With
End Sub
 
A

Andrea

Great...I am going to give this a try on Monday Jay. I will let you know how
it works out.

Thanks so much!

Andrea
 

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