Share via


How Do I Insert A Line Break To A Word Document Programatically?

Question

Monday, June 16, 2014 3:38 PM

In Word 2010, adding a "\n" character to the text of a Range adds a paragraph break, which adds more space than a line break does. I have tried: "\n", "\u2028\n", '\r", and "\r\n" all of which seems to add a paragraph break. How can I add a line break (like when I press <shift-enter> manually in word)? I am using C# in Visual Studio 2013. Thank you in advance for the help.

All replies (2)

Monday, June 16, 2014 8:53 PM âś…Answered

After several hours of experimentation and research, I managed to figure it out! The vertical tab character "\v" did the trick. While I'm not sure if it's "technically" the same as a line break, it appears to make the exact same amount of space as one, so it works for my purposes.


Tuesday, June 17, 2014 3:28 AM | 2 votes

A manual line break in Word is created via Chr(11).

Cheers
Paul Edstein
[MS MVP - Word]