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)
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)