Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert multi-line text in Form Field from UserForm...

Status
Not open for further replies.

MeisoT

Technical User
Apr 25, 2004
43
US
I have a UserForm that I use to collect data. I'm trying to assign text to a form field from two separate text boxes on the UserForm. It should work like this:

Enter Text1 from UserForm on 1st line of Form Field
Enter Text2 from UserForm on 2nd line of Form Field

If the user were entering manually, they would go to the Form Field, enter Text1, Hit Return, Enter Text2 on the next line of the SAME form field.

I tried different variations of the following, but the text is not being inserted INTO the field, it is being inserted before or after the form field:

ActiveDocument.FormFields("myField").Select

With Selection
.InsertAfter (Text1.Value)
.TypeParagraph
.InsertAfter (Text2.Value)
End With

I'm using Word 2000. Can anyone help?

 
Assuming the textboxes on your form are Text1 and Text2 - and they should in fact be explicitly named -


Code:
Dim strTextInput As String
strTextInput = Text.Text & " " & Text2.Text
ActiveDocument.FormFields("myField).Result = strTextInput

Code:
ActiveDocument.FormFields("myField).Result = _
   Text>Text & " " & Text2.Text

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top