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 > Element

The Element Object


This class is used to represent a region of the document that can be edited. This is the main class for manipulating the Word object model. Most elements of a Document inherit from the Element class.

You cannot create a new Element object by using the new keyword. There are various properties

The following sample demonstrates getting an Element object by retrieving a section's header:



Examples:

[csharp]
WordApplication app = new WordApplication();
Document doc = app.Open(@"C:\sample.doc");
Section sect = doc.Sections[0];
Element e = sect.Header;
[vbnet]
Dim app As New WordApplication()
Dim doc As Document = app.Open("C:\sample.doc")
Dim sect As Section = doc.Sections(0)
Dim e As Element = sect.Header


Element Enumerations

NameDescription
Element.BreakTypeAn Element.BreakType value specifies the type of break to insert before or after a region in the document.
Element.Type

An Element represents a region of the document that can be edited



Element Properties

Property Type Access Description
Children Element[] read

Returns a collection of Elements that represents all the direct children of the current element

Elements Element[] read

Returns a collection of Elements that represent all the elements in the document of the specified type

ElementType Element.Type read

Returns an Element.Type object that represents the type of this element

Length int read

Returns an int that represents the number of characters in this Element

Start int read

Returns an int that represents the absolute character index of the start of this Element

Text String read

Returns a String that represents the text for this Element



Element Methods

ReturnsSignature and Description
void CreateBookmark ( String name )

Creates a bookmark on this Element with the specified name

Section CreateSectionAfter ( )

Creates and returns a Section object that represents a new section at the end of this Element

Section CreateSectionBefore ( )

Creates and returns a Section object that represents a new section at the beginning of this Element

void DeleteElement ( )

Deletes all the text and properties of this Element

Position GetPosition ( int offset )

Returns a Position object that represents the location specified by the offset

Table ImportData ( Object[,] data )

Imports the data from a rectangular array into a Table at the point of the current element in the document

Table ImportData ( Object[,] data , String[] columnNames , DataImportProperties props )

Imports the data from a rectangular array into a Table at the point of the current element in the document

Table ImportData ( Object[][] data )

Imports the data from a 2-dimensional array into a Table at the point of the current element in the document

Table ImportData ( Object[][] data , String[] columnNames , DataImportProperties properties )

Imports a set of data from an array of column names and a 2-dimensional array of data to a Table created at the point of the current element in the document

Table ImportData ( System.Data.DataTable data )

Imports data from a DataTable into a Table at the point of this Element in the document

Table ImportData ( System.Data.DataTable data , DataImportProperties props )

Imports data from a DataTable into a Table at the point of this Element in the document

Table ImportData ( System.Data.DataView data )

Imports data from a DataView into a Table at the point of this Element in the document

Table ImportData ( System.Data.DataView data , DataImportProperties props )

Imports data from a DataView into a Table at the point of this Element in the document

Table ImportData ( System.Data.IDataReader data )

Imports the data from a DataReader into a Table at the point of the current element in the document

Table ImportData ( System.Data.IDataReader data , DataImportProperties props )

Imports the data from a DataReader into a Table at the point of the current element in the document

void InsertAfter ( Element element )

Inserts an existing element after this element

void InsertBefore ( Element element )

Inserts an existing element before this element

void InsertBreakAfter ( Element.BreakType type )
void InsertBreakBefore ( Element.BreakType type )
Hyperlink InsertHyperlinkAfter ( String url , String display )

Creates and returns a Hyperlink at the beginning of this Element

Hyperlink InsertHyperlinkBefore ( String url , String display )

Creates and returns a Hyperlink at the beginning of this Element

InlineImage InsertImageAfter ( String fileName )

Inserts and returns an InlineImage at the end of this Element

InlineImage InsertImageAfter ( System.IO.Stream stream )

Inserts and returns an InlineImage at the end of this Element

InlineImage InsertImageBefore ( String fileName )

Inserts and returns an InlineImage at the beginning of this Element

InlineImage InsertImageBefore ( System.IO.Stream stream )

Inserts and returns an InlineImage at the beginning of this Element

List InsertListAfter ( boolean numbered )

Creates and returns an empty List at the end of this Element

List InsertListBefore ( boolean numbered )

Creates and returns an empty List at the beginning of this Element

MergeField InsertMergeFieldAfter ( String fieldName , String display )

Creates and returns a MergeField at the end of this Element

MergeField InsertMergeFieldBefore ( String fieldName , String display )

Creates and returns a MergeField at the beginning of this Element

Paragraph InsertParagraphAfter ( NamedStyle style )

Creates and returns a Paragraph object that represents a new empty paragraph at the end of this Element

Paragraph InsertParagraphAfter ( NamedStyle style , ParagraphFormatting props )

Creates and returns a Paragraph object that represents a new empty paragraph at the end of this Element

Paragraph InsertParagraphBefore ( NamedStyle style )

Creates and returns a Paragraph object that represents a new empty paragraph at the beginning of this Element

Paragraph InsertParagraphBefore ( NamedStyle style , ParagraphFormatting props )

Creates and returns a Paragraph object that represents a new empty paragraph at the beginning of this Element

Table InsertTableAfter ( int rows , int columns )

Creates and returns a Table at the end of this Element

Table InsertTableAfter ( int rows , int columns , TableFormatting props )

Creates and returns a Table at the end of this Element

Table InsertTableBefore ( int rows , int columns )

Creates and returns a Table at the beginning of this Element

Table InsertTableBefore ( int rows , int columns , TableFormatting props )

Creates and returns a Table at the beginning of this Element

CharacterRun InsertTextAfter ( String text , boolean newRun )

Creates and returns a CharacterRun at the end of this Element

CharacterRun InsertTextAfter ( String text , Font props )

Creates and returns a CharacterRun at the end of this Element

CharacterRun InsertTextBefore ( String text , boolean newRun )

Creates and returns a CharacterRun at the beginning of this Element

CharacterRun InsertTextBefore ( String text , Font props )

Creates and returns a CharacterRun at the beginning of this Element

SearchMatch[] Search ( String toMatch )
Searches for a specified string and returns an Iterator that can be used to iterate over the results.
int SearchAndReplace ( String search , String replaceWith )
Searches for a string specified by the search parameter, and replaces it with the string specified by the replaceWith parameter.
Element SubElement ( int start , int end )

Creates and returns a Element object that represents a sub Element within this Element based on the specified start and end offsets



Copyright 2007 © SoftArtisans, Inc. All Rights Reserved.