We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Inserting Line Breaks with .Replace() method

Hi there everybody,
I’m cannot find how to insert Line Breaks with the .Replace() method of the Document.Range class.
For example, I have a .dot model document containing the string “\n” several times. I open it with the following code:

Dim doc As Aspose.Words.Document = New Aspose.Words.Document(“MyDoc.dot”)

Then as said I wish to replace the “\n” instances by a Line Break:

doc.Range.Replace("\n", BreakType.LineBreak, False, False)

But it does nothing… What does I have missed?


Thanks for your inquiry. Could you please attach your input document here for testing? I will check the problems on my side and provide you more information.

Best regards,

Hi AndreyN,
There is a sample of doc in attachement.
Thanks in advance.


Thank you for additional information. Please try using the following code:
Dim doc As New Document(“sample_aspose.dot”)
doc.Range.Replace("\n", ControlChar.LineBreak, False, False)

Best regards,

Thank you so very much, it works great! :slight_smile:
Thank you for your reactivity. See you soon.