Problem with insert mulitline in text content control.

P

pmm

In a userdefined dialogbox there are textboxs. Textbox with one linje
is working fine, but not with multilines.
I first clean-up the text in the mulitiline textbox and replace vbCr
with vbCrLf:

Dim objCC As ContentControls
Dim txt1 As String
Dim txt2 As String
Dim posTab As Integer

txt1 = Trim(.TextBoxADRESS.Text)
txt2 = ""
posTab = 1
Do While 0 < posTab
posTab = InStr(1, txt1, vbCr)
If 0 < posTab Then
txt2 = txt2 & Left(txt1, posTab - 1) & vbCrLf
txt1 = Mid(txt1, posTab + 2)
Else
txt2 = txt2 & txt1
End If
Loop

And then the text is inserting in a text content control:

Set objCC = ActiveDocument.SelectContentControlsByTag("Adress")
objCC(1).Range.Text = txt2

The error is in the last line

What do I wrong?

(Thanks for the answer)
 
P

pmm

In a userdefined dialogbox there are textboxs. Textbox with one linje
is working fine, but not with multilines.
I first clean-up the text in the mulitiline textbox and replace vbCr
with vbCrLf:

Dim objCC As ContentControls
Dim txt1 As String
Dim txt2 As String
Dim posTab As Integer

txt1 = Trim(.TextBoxADRESS.Text)
txt2 = ""
posTab = 1
Do While 0 < posTab
   posTab = InStr(1, txt1, vbCr)
   If 0 < posTab Then
      txt2 = txt2 & Left(txt1, posTab - 1) & vbCrLf
      txt1 = Mid(txt1, posTab + 2)
   Else
      txt2 = txt2 & txt1
   End If
Loop

And then the text is inserting in a text content control:

Set objCC = ActiveDocument.SelectContentControlsByTag("Adress")
objCC(1).Range.Text = txt2

The error is in the last line

What do I wrong?

(Thanks for the answer)

I have self found the soloutions, and it have take time som times to
get here:
The group area must first ungroup and then it is possible to insert
multiline
 

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