M
matchorno
I am trying to insert some text into a protected Word text field with
carriage returns for new lines via VBA code. For example, I would like to
enter something like the following into a text field called Text1:
Test Line 1
Test Line 2
Test Line 3
So my code is:
ActiveDocument.FormFields("Text1").Result = "Test Line 1" & Chr(13) & "Test
Line 2" & Chr(13) & "Test Line 3"
The text field is located inside of a table cell. The problem is that it is
inserting the box symbol for chr(13) instead of a new line. So it looks like
this: Test Line 1[]Test Line 2[]Test Line 3.
I've tried playing around with different carriage returns such as vbcrlf and
chr(10) as well as combinations such as chr(13) & chr(10), but the same thing
happens.
The weird thing is that if the text field is NOT located inside a table, it
works just fine. But if the text field is inside of a table, it gives me the
squares. I really need to keep it inside a table, as that is how the form is
laid out. Also weird is that I have a second field (also inside a table)
called Text2 which is a calculated field, which basically mirrors the Text1
field. While Text1 has the square symbol, the calculated field doesn't...and
looks fine even though it is part of a table too. I tried playing around with
different table settings like wrap text, setting a row size, not setting a
row size, etc. to no avail.
I can't seem to find the answer on any existing forums. Any help is greatly
appreciated as I've been at this for an entire day now.
Thanks!!
carriage returns for new lines via VBA code. For example, I would like to
enter something like the following into a text field called Text1:
Test Line 1
Test Line 2
Test Line 3
So my code is:
ActiveDocument.FormFields("Text1").Result = "Test Line 1" & Chr(13) & "Test
Line 2" & Chr(13) & "Test Line 3"
The text field is located inside of a table cell. The problem is that it is
inserting the box symbol for chr(13) instead of a new line. So it looks like
this: Test Line 1[]Test Line 2[]Test Line 3.
I've tried playing around with different carriage returns such as vbcrlf and
chr(10) as well as combinations such as chr(13) & chr(10), but the same thing
happens.
The weird thing is that if the text field is NOT located inside a table, it
works just fine. But if the text field is inside of a table, it gives me the
squares. I really need to keep it inside a table, as that is how the form is
laid out. Also weird is that I have a second field (also inside a table)
called Text2 which is a calculated field, which basically mirrors the Text1
field. While Text1 has the square symbol, the calculated field doesn't...and
looks fine even though it is part of a table too. I tried playing around with
different table settings like wrap text, setting a row size, not setting a
row size, etc. to no avail.
I can't seem to find the answer on any existing forums. Any help is greatly
appreciated as I've been at this for an entire day now.
Thanks!!