Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Wiki Markup
{description}
{excerpt}The [CharacterRun|CharacterRun] class represents a contiguous run of characters in the document, all of which have the same formatting.{excerpt}
{signature:C#}
 public sealed class CharacterRun : Element
{signature}{signature:vb.net}
Public NotInheritable Class CharacterRun
		Inherits Element
{signature}
{remarks}To insert a new character run into a document, use [Element.InsertTextBefore()|Element.InsertTextBefore] or [Element.InsertTextAfter()|Element.InsertTextAfter].  To get an existing character run, use [Element.GetElements(Element.Type.CharacterRun)|Element.GetElements(Element.Type)] or [Element.Children|Element.Children] and check which elements are of type [Element.Type.CharacterRun|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.

{remarks}
{example}{code:csharp|title=C#}

          //--- 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];
        {code}
{code:vb.net|title=vb.net}

          '--- 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)
        {code}

{example}
{properties}
||Name||Description||
|[Deleted|CharacterRun.Deleted]|{excerpt-include:CharacterRun.Deleted|nopanel=true}|
|[DeletedBy|CharacterRun.DeletedBy]|{excerpt-include:CharacterRun.DeletedBy|nopanel=true}|
|[DeletedTime|CharacterRun.DeletedTime]|{excerpt-include:CharacterRun.DeletedTime|nopanel=true}|
|[Font|CharacterRun.Font]|{excerpt-include:CharacterRun.Font|nopanel=true}|
|[ModifiedBy|CharacterRun.ModifiedBy]|{excerpt-include:CharacterRun.ModifiedBy|nopanel=true}|
|[ModifiedTime|CharacterRun.ModifiedTime]|{excerpt-include:CharacterRun.ModifiedTime|nopanel=true}|
|[New|CharacterRun.New]|{excerpt-include:CharacterRun.New|nopanel=true}|
|[PropertiesChangedBy|CharacterRun.PropertiesChangedBy]|{excerpt-include:CharacterRun.PropertiesChangedBy|nopanel=true}|
|[PropertiesChangedTime|CharacterRun.PropertiesChangedTime]|{excerpt-include:CharacterRun.PropertiesChangedTime|nopanel=true}|
|[Style|CharacterRun.Style]|{excerpt-include:CharacterRun.Style|nopanel=true}|