Userform text field preset

S

Sol Apache

I am creating a letterhead template with a userform which has some of its
fields containing default data. I insert the default text in the ³Text²
field of the Properties list.

One of the fields has several lines of text, and the field is set to
Multiline = True but each time I try to insert the 2nd line of text it
overwrites the one I have already typed in.

Is there any way of having multiple line default text?

TIA
 
G

Greg Maxey

I think when you use multiline then the text that you want to type in
th text field wraps automatically to the available line length.
 
J

Jean-Guy Marcil

Sol Apache was telling us:
Sol Apache nous racontait que :
I am creating a letterhead template with a userform which has some of
its fields containing default data. I insert the default text in the
³Text² field of the Properties list.

One of the fields has several lines of text, and the field is set to
Multiline = True but each time I try to insert the 2nd line of text it
overwrites the one I have already typed in.

Is there any way of having multiple line default text?

Yes.

How are you inserting this second line?

Three ways:
1) While in the VBA editor, select your textbox. Wait a few seconds and
click on it again (Just make sure you do not do an actual double-click
because this will take you to the code pane with a Click event sub), you
should be able to type the default text directly in the text box instead of
going through the properties pane. Now, as you type, if, as you say,
MultiLine is set to True, the text will automatically wrap to the next line
when you get to the end. You can force a new line by hitting CTRL-Enter

2) Just type the text in the Text property in the properties pane, if it is
too long, it will automatically wrap.

3) Use something like this in the Initialize event:

Private Sub UserForm_Initialize()

Me.TextBox1.Text = "This is the default text that should be" & vbCrLf &
"on many lines becasue it is too long."

End Sub

Here I used a vbCrLf to force a nee line, but you could remove " & vbCrLf &
" and replace it by a single space and the text would automatically wrap.


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
S

Sol Apache

Hi Greg
Thanks, but I don¹t want this. It is an address field so the lines will be
of different lengths with a return at the end.

The mutliline=yes allows the user to press return within the field to create
a new line of text.

I cannot restrict this field to certain line lengths, or to have separate
fields for the address, because the user may want to enter an alternate to
the default address with a different number of lines and of varying line
lengths.

So the text property field does not allow a default multi line entry?
 
S

Sol Apache

Thank you very much
Just tried this and it works, but on a Mac you have to press shift+return to
get it to a new line while in the editor. When the user is filling in the
form, s/he can press return for a new line.

Your email crossed my reply to Greg¹s


Thx very much for your help and suggestions.


Sol
 

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