The CharacterRun class represents a contiguous run of characters in the document, all of which have the same formatting.

 public sealed class CharacterRun : Element
Public NotInheritable Class CharacterRun
		Inherits Element

To insert a new character run into a document, use Element.InsertTextBefore() or Element.InsertTextAfter(). To get an existing character run, use Element.GetElements(Element.Type.CharacterRun) or Element.Children and check which elements are of type Element.Type.CharacterRun.

The following sample demonstrates inserting a new character run into a document and retrieving the first character run from an existing document.


          //--- Insert a character run at the end of the document
          WordApplication app = new WordApplication();
          Document doc = app.Create();
          CharacterRun run = doc.InsertTextAfter("Hello world!", true);

          //--- Get the first character run of an existing document
          WordApplication app = new WordApplication();
          Document doc = app.Open(@"C:\sample.doc");
          CharacterRun firstCharRun =
               (CharacterRun)doc.GetElements(Element.Type.CharacterRun)[0];
        

          '--- Insert a character run at the end of the document
          Dim app As New WordApplication()
          Dim doc As Document = app.Create()
          Dim run As CharacterRun = doc.InsertTextAfter("Hello world!", True)

          '--- Get the first character run of an existing document
          Dim app As New WordApplication()
          Dim doc As Document = app.Open("C:\sample.doc")
          Dim firstCharRun As CharacterRun = _
               doc.GetElements(Elements.Type.CharacterRun)(0)
        

Name

Description

Deleted

DeletedBy

DeletedTime

Font

ModifiedBy

ModifiedTime

New

PropertiesChangedBy

PropertiesChangedTime

Style