/// <summary>/// Inserts the given <param name="text"/> at the cursor bookmark in the <param name="docName"/>/// </summary>/// <param name="docName">Name of the document.</param>/// <param name="text">The text to insert into the document.</param>public static void InsertTextBeforeCursorInWordprocessingDocument(string docName, string text){ // Open the Wordprocessing document. using (WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(docName, true)) { BookmarkStart cursorBookmark = wordprocessingDocument.MainDocumentPart.Document.Body.Descendants<BookmarkStart>().Where( bookmarkStart => bookmarkStart.Name.HasValue && bookmarkStart.Name.Value.Equals("_GoBack")).SingleOrDefault(); if (cursorBookmark != null) { Text docText = new Text(text); Run run = new Run(docText); cursorBookmark.Parent.InsertBefore(run, cursorBookmark); } // Save changes to the main document part. wordprocessingDocument.MainDocumentPart.Document.Save(); }}