This project has moved and is read-only. For the latest updates, please go here.

Paragraph ReplaceText fails with line breaks

Nov 11, 2009 at 3:04 PM

The following code will fail with exception message "Object reference not set to an instance of an object."

DocX doc = DocX.Create(@"LineBreakTest.docx"); Paragraph p = doc.InsertParagraph(); string originalText = "TO:\n $Customer.Name,"; string replaceText = "TO:\n John Smith,"; p.Append("TO:\n $Customer.Name,"); p.ReplaceText(originalText, replaceText, false);

This error only occurs when there is a line break "\n" in the text.
I've tried appending the new text and then removing the original text but this also fails on the remove, additionally trying to replace the "\n" on their own first also fails.

Any ideas?