Description
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 theElement
class.
C#
vb.net
Remarks
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
C#
vb.net
Properties
Name | Description |
---|---|
Returns a collection of Element objects that represents all the direct children of the current element. | |
Returns an Element.Type object that represents the type of this element. | |
Returns an int that represents the number of characters in this Element. | |
Returns an int that represents the absolute character index of the start of this Element. | |
Returns a String that represents the text for this Element. |
Methods
Name | Description |
---|---|
Creates a bookmark on this Element with the specified name. | |
Creates and returns a Section object that represents a new section at the end of this Element. | |
Creates and returns a Section object that represents a new section at the beginning of this Element. | |
Deletes all the text and properties of this Element. The element then is no longer a valid element of the type. It is now just a position of where that element used to be. | |
Returns a collection of Element objects that represent the first level of elements in the document of the specified type. GetElements does not return nested elements. | |
Returns a Position object that represents the location specified by the offset. The Position object can be used similar to a cursor. | |
Imports the data from a 2-dimensional array into a Table at the point of the current element in the document. | |
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. Also accepts a DataImportProperties object defining any options for this data import. | |
Imports data from a DataTable into a Table at the point of this Element in the document. | |
Imports data from a DataTable into a Table at the point of this Element in the document. Also accepts a DataImportProperties object that contains the options for importing. | |
Imports data from a DataView into a Table at the point of this Element in the document. | |
Imports data from a DataView into a Table at the point of this Element in the document. Also accepts a DataImportProperties object that contains the options for importing. | |
Imports the data from a rectangular array into a Table at the point of the current element in the document. | |
Imports the data from a rectangular array into a Table at the point of the current element in the document. Also accepts an array of column names and a DataImportProperties object with the import options. | |
Imports the data from a DataReader into a Table at the point of the current element in the document. | |
Imports the data from a DataReader into a Table at the point of the current element in the document. Also accepts a DataImportProperties object that contains the import options. | |
Inserts an existing element after this element. A copy of the Element passed in is placed after this element | |
Inserts an existing element before this element. A copy of the Element passed in is placed before this element | |
Inserts a break of the specified type after the element. | |
Inserts a break of the specified type before the element. | |
Creates and returns a Hyperlink at the beginning of this Element. This hyperlink will have the specified url and displayed text. | |
Creates and returns a Hyperlink at the beginning of this Element. This hyperlink will have the specified url and displayed text. | |
Inserts and returns an InlineImage at the end of this Element. The image that will be inserted is specified by the stream parameter. | |
Inserts and returns an InlineImage at the end of this Element. The image that will be inserted is specified by the fileName parameter. | |
Inserts and returns an InlineImage at the beginning of this Element. The image that will be inserted is specified by the fileName parameter. | |
Inserts and returns an InlineImage at the beginning of this Element. The image that will be inserted is specified by the stream parameter. | |
Creates and returns an empty List at the end of this Element. By passing a boolean, it can be a numbered list (true) or a bulleted list (false). | |
Creates and returns an empty List at the beginning of this Element. By passing a boolean, it can be a numbered list (true) or a bulleted list (false). | |
Creates and returns a MergeField at the end of this Element. This merge field will have the specified name and contents. | |
Creates and returns a MergeField at the beginning of this Element. This merge field will have the specified name and contents. | |
Creates and returns a Paragraph object that represents a new empty paragraph at the end of this Element. The paragraph that is inserted will have the style specified. If this Element is in the middle of a paragraph, the containing paragraph will be split. | |
Creates and returns a Paragraph object that represents a new empty paragraph at the end of this Element. The paragraph that is inserted will have the style specified, to which any additional specified paragraph formatting is applied as well. If this Element is in the middle of a paragraph, the containing paragraph will be split. | |
Creates and returns a Paragraph object that represents a new empty paragraph at the beginning of this Element. The paragraph that is inserted will have the style specified. If this Element is in the middle of a paragraph, the containing paragraph will be split. | |
Creates and returns a Paragraph object that represents a new empty paragraph at the beginning of this Element. The paragraph that is inserted will have the style specified, to which any additional specified paragraph formatting is applied as well. If this Element is in the middle of a paragraph, the containing paragraph will be split. | |
Creates and returns a Table at the end of this Element. The table will contain the specified number of rows and columns. | |
Creates and returns a Table at the end of this Element. The table will contain the specified number of rows and columns. It will also be formatted with the properties specified. | |
Creates and returns a Table at the beginning of this Element. The table will contain the specified number of rows and columns. | |
Creates and returns a Table at the beginning of this Element. The table will contain the specified number of rows and columns. It will also be formatted with the properties specified. | |
Creates and returns a CharacterRun at the end of this Element. The text to be inserted is specified as well as whether this should be a new character run or part of the previous one. | |
Creates and returns a CharacterRun at the end of this Element. The text to be inserted is specified as well as the font that should override the font found in the style of the character run's enclosing paragraph. | |
Creates and returns a CharacterRun at the beginning of this Element. The text to be inserted is specified as well as whether this should be a new character run or part of the existing one. | |
Creates and returns a CharacterRun at the beginning of this Element. The text to be inserted is specified as well as the font that should override the font found in the style of the character run's enclosing paragraph. | |
Searches for a specified string and returns a collection of type SearchMatch[]. | |
Searches for a string specified by the search parameter, and replaces it with the string specified by the replaceWith parameter. The search string can be a literal, a regular expression, or a combination of both. Since the string can contain regular expressions, use a backslash to escape special characters. Special characters are [^$.|?*+() . | |
Creates and returns a Element object that represents a sub Element within this Element based on the specified start and end offsets. |
Extension Methods
Overload | Description |
---|---|
Imports the data from a SharePoint List into a Table at the point of the current element in the document. | |
ImportData(Microsoft.SharePoint.SPView, Microsoft.SharePoint.SPList, DataImportProperties) | Imports the data from a SharePoint View into a Table at the point of the current element in the document. Also accepts a SharePoint List to which the View belongs and a DataImportProperties object with the import options. |
Nested Classes
Name | Description |
---|---|
An Element.BreakType value specifies the type of break to insert Element.InsertBreakBefore or Element.InsertBreakAfter a region in the document. | |
An Element represents a region of the document that can be edited. An Element.Type value specifies the type of region an Element object represents. |