officefileapi-116822-word-processing-document-api-examples-text-how-to-append-text-to-the-paragraph.md
The following code snippet appends text to the end of the last paragraph.
using DevExpress.XtraRichEdit.API.Native;
using System.Linq;
using (var wordProcessor = new RichEditDocumentServer())
{
// Access a document.
Document document = wordProcessor.Document;
// Start to edit the document.
document.BeginUpdate();
// Append text
document.AppendText("First Paragraph\nSecond Paragraph\nThird Paragraph");
// Obtain the last paragraph's end position.
DocumentPosition paragraphEnd = document.Paragraphs.Last().Range.End;
// Insert text to the paragraph end.
document.InsertText(paragraphEnd, "<<Appended to Paragraph End>>");
// Finalize to edit the document.
document.EndUpdate();
}
Imports Microsoft.VisualBasic
Imports DevExpress.XtraRichEdit.API.Native
Imports System.Linq
Using wordProcessor = New RichEditDocumentServer()
' Access a document.
Dim document As Document = wordProcessor.Document
' Start to edit the document.
document.BeginUpdate()
' Append text
document.AppendText("First Paragraph" & ControlChars.Lf & "Second Paragraph" & ControlChars.Lf & "Third Paragraph")
' Obtain the last paragraph's end position.
Dim paragraphEnd As DocumentPosition = document.Paragraphs.Last().Range.End
' Insert text to the paragraph end.
document.InsertText(paragraphEnd, "<<Appended to Paragraph End>>")
' Finalize to edit the document.
document.EndUpdate()
End Using