Replacing text with text with a line break in it

Lets say I want to replace the text:
"Text to Replace"


with
"Hello
World"

Where that’s a <w:br/> between Hello and World in the docx. How would I go about that?

d.Range.Replace(textToReplace, replaceWith, true, false) ends up spitting out
Hello?World
if I include a newline character in it.

I worked out that if I replace 0x2028 (unicode line break) with ‘\v’ that it will correctly insert a line break at that spot.

Hi Simon,


Thanks for your inquiry. It is great you were able to find what you were looking for. Please let us know any time you have any further queries.

Best regards,