Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Description

Excerpt

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

|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)
        
Signature
C#C#
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}{signature:vb.net
vb.net
}
Public NotInheritable Class CharacterRun
		Inherits Element
Remarks
To insert a new character run into a document, use
{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
.

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

Example
Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle
Properties

...

Name

...

Description

...

Deleted

...

{code}

{example}
{properties}
||Name||Description||
|[Deleted|CharacterRun.Deleted]|{excerpt-include:CharacterRun.Deleted

...

DeletedBy

|nopanel=true}|
|[DeletedBy|CharacterRun.DeletedBy]|{excerpt-include

...

:CharacterRun.DeletedBy

...

DeletedTime

|nopanel=true}|
|[DeletedTime|CharacterRun.DeletedTime]|{excerpt-include

...

:CharacterRun.DeletedTime

...

Font

|nopanel=true}|
|[Font|CharacterRun.Font]|{excerpt-include

...

:CharacterRun.Font

...

ModifiedBy

|nopanel=true}|
|[ModifiedBy|CharacterRun.ModifiedBy]|{excerpt-include

...

:CharacterRun.ModifiedBy

...

ModifiedTime

|nopanel=true}|
|[ModifiedTime|CharacterRun.ModifiedTime]|{excerpt-include

...

:CharacterRun.ModifiedTime

...

New

|nopanel=true}|
|[New|CharacterRun.New]|{excerpt-include

...

:CharacterRun.New

...

PropertiesChangedBy

|nopanel=true}|
|[PropertiesChangedBy|CharacterRun.PropertiesChangedBy]|{excerpt-include

...

:CharacterRun.PropertiesChangedBy

...

PropertiesChangedTime

|nopanel=true}|
|[PropertiesChangedTime|CharacterRun.PropertiesChangedTime]|{excerpt-include

...

:CharacterRun.PropertiesChangedTime

...

Style

|nopanel=true}|
|[Style|CharacterRun.Style]|{excerpt-include

...

:CharacterRun.Style

...

|nopanel=true}|