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 / August 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrea - 10 Aug 2005 23:13 GMT
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  :)
Anne Troy - 10 Aug 2005 23:47 GMT
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

> 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
[quoted text clipped - 23 lines]
> Any help is appreciated!
> Andrea  :)
Andrea - 11 Aug 2005 00:40 GMT
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


> 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
[quoted text clipped - 30 lines]
> > Any help is appreciated!
> > Andrea  :)
Anne Troy - 11 Aug 2005 01:39 GMT
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

> Hi Anne, thank you for the suggestion, it is a very creative work around.
> :)
[quoted text clipped - 50 lines]
>> > Any help is appreciated!
>> > Andrea  :)
Jay Freedman - 11 Aug 2005 04:57 GMT
>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
[quoted text clipped - 21 lines]
>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).

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Jay Freedman - 11 Aug 2005 14:56 GMT
>> 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
[quoted text clipped - 49 lines]
> Jay Freedman
> Microsoft Word MVP        FAQ: http://word.mvps.org

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

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

Andrea - 11 Aug 2005 18:28 GMT
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

> >> 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
[quoted text clipped - 64 lines]
>     End With
> End Sub
Andrea - 26 Aug 2005 01:39 GMT
Hi Jay, your code below worked perfectly.

Thanks so much!
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
[quoted text clipped - 64 lines]
>     End With
> End Sub
 
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.