Forums     Knowledge Base     OfficeWriter Online     
 
 
This documentation is for
OfficeWriter v3.8.1
.NET Platform

View Docs for Another
Version or Platform

Programmer's Reference > WordApplication API > CharacterRun

The CharacterRun Object

     extends Element



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

To insert a new character run into a document, use Element.InsertTextBefore() or Element.InsertTextAfter(). To get an existing character run, use Element.Elements(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.



Examples:

[csharp]
// 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.Elements(Element.Type.CharacterRun)[0];
[vbnet]
' 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 = _
 CType(doc.Elements(Elements.Type.CharacterRun)(0), CharacterRun)


Please note that this object inherits methods and properties not shown here from the following objects:

CharacterRun Properties

Property Type Access Description
Deleted boolean read

Returns a boolean that represents if this character run was deleted with revision tracking on

DeletedBy String read

Returns a String that represents the name of the author who deleted the text in this character run (if revision tracking was on when it was deleted -- Deleted returns true)

DeletedTime Date read

Returns a DateTime object that represents the date and time the text in this character run was deleted (if revision tracking was on when it was deleted -- Deleted returns true)

Font Font read
write
Sets or returns a font for the CharacterRun.
ModifiedBy String read

Returns a String that represents the name of the author who inserted the text in this character run (if revision tracking was on when it was modified)

ModifiedTime Date read

Returns a DateTime object that represents the date and time the text in this character run was inserted (if revision tracking was on when it was modified)

New boolean read

Returns a boolean that represents if this character run was added while revision tracking was turned on

PropertiesChangedBy String read

Returns a String that represents the name of the author who modified the properties of this character run

PropertiesChangedTime Date read

Returns a DateTime object that represents the date and time the properties of this character run were modified

Style NamedStyle read
write

Sets or Returns a NamedStyle object that represents the Style of this character run



This object does not have any methods defined.



Copyright 2007 © SoftArtisans, Inc. All Rights Reserved.