OfficeIMO

API Reference

Class

WordDocument

Namespace OfficeIMO.Word
Assembly OfficeIMO.Word
Implements
IDisposable

Defines default document settings parts.

Inheritance

  • Object
  • WordDocument

Constructors

Methods

AcceptRevisions 2 overloads
public Void AcceptRevisions(String authorName) #
Returns: Void

Given author name, accept all revisions by given Author

Parameters

authorName System.String requiredposition: 0
public Void AcceptRevisions() #
Returns: Void

Accept all revisions in the document

public WordParagraph AddBookmark(String bookmarkName) #
Returns: WordParagraph

Inserts a bookmark in a new paragraph.

Parameters

bookmarkName System.String requiredposition: 0
Name of the bookmark.

Returns

The created WordParagraph.

public WordParagraph AddBreak(Nullable<BreakValues> breakType = null) #
Returns: WordParagraph

Inserts a break into the document.

Parameters

breakType System.Nullable{DocumentFormat.OpenXml.Wordprocessing.BreakValues} = null optionalposition: 0
Type of break to insert.

Returns

The created WordParagraph containing the break.

public WordChart AddChart(String title = "", Boolean roundedCorners = false, Int32 width = 600, Int32 height = 600) #
Returns: WordChart

Adds the chart to the document. The type of chart is determined by the type of data passed in. You can use multiple: .AddBar() to add a bar chart .AddLine() to add a line chart .AddPie() to add a pie chart .AddArea() to add an area chart .AddScatter() to add a scatter chart .AddRadar() to add a radar chart .AddBar3D() to add a 3-D bar chart. .AddPie3D() to add a 3-D pie chart. .AddLine3D() to add a 3-D line chart. You can't mix and match the types of charts, except bar and line which can coexist in a combo chart.

Parameters

title System.String = "" optionalposition: 0
The title.
roundedCorners System.Boolean = false optionalposition: 1
if set to true [rounded corners].
width System.Int32 = 600 optionalposition: 2
The width.
height System.Int32 = 600 optionalposition: 3
The height.

Returns

WordChart

public WordParagraph AddCitation(String sourceTag) #
Returns: WordParagraph

Inserts a citation field referencing the specified source tag.

Parameters

sourceTag System.String requiredposition: 0
Tag of the bibliographic source.

Returns

The created WordParagraph.

public WordChart AddComboChart(String title = "", Boolean roundedCorners = false, Int32 width = 600, Int32 height = 600) #
Returns: WordChart

Creates a chart ready for combining bar and line series. Use String>) to supply category labels and then call Color) or Color) to add data. The call to AddChartAxisX must be performed before adding any series so both chart types share the same axes.

Parameters

title System.String = "" optionalposition: 0
roundedCorners System.Boolean = false optionalposition: 1
width System.Int32 = 600 optionalposition: 2
height System.Int32 = 600 optionalposition: 3
public WordCoverPage AddCoverPage(CoverPageTemplate coverPageTemplate) #
Returns: WordCoverPage

Adds a built-in cover page to the document.

Parameters

coverPageTemplate OfficeIMO.Word.CoverPageTemplate requiredposition: 0
Cover page template to use.

Returns

The created WordCoverPage.

AddCustomBulletList 3 overloads
public WordList AddCustomBulletList(Char symbol, String fontName, String colorHex, Nullable<Int32> fontSize = null) #
Returns: WordList

Adds a custom bullet list with formatting options.

Parameters

symbol System.Char requiredposition: 0
Bullet symbol.
fontName System.String requiredposition: 1
Font name for the symbol.
colorHex System.String requiredposition: 2
Hex color of the symbol.
fontSize System.Nullable{System.Int32} = null optionalposition: 3
Font size in points.

Returns

The created WordList.

public WordList AddCustomBulletList(WordListLevelKind kind, String fontName, Nullable<Color> color = null, String colorHex = null, Nullable<Int32> fontSize = null) #
Returns: WordList

Adds a custom bullet list with formatting options.

Parameters

symbol OfficeIMO.Word.WordBulletSymbol requiredposition: 0
Bullet symbol.
fontName System.String requiredposition: 1
Font name for the symbol.
color System.Nullable{SixLabors.ImageSharp.Color} = null optionalposition: 2
Bullet color.
colorHex System.String = null optionalposition: 3
Hex color fallback.
fontSize System.Nullable{System.Int32} = null optionalposition: 4
Font size in points.

Returns

The created WordList.

AddCustomBulletList(OfficeIMO.Word.WordListLevelKind kind, System.String fontName, System.Nullable{SixLabors.ImageSharp.Color} color, System.String colorHex, System.Nullable{System.Int32} fontSize) #

Adds a custom bullet list using the specified formatting.

Parameters

kind OfficeIMO.Word.WordListLevelKind required
Bullet level kind.
fontName System.String required
Font name for the bullet.
color System.Nullable{SixLabors.ImageSharp.Color} required
Bullet color.
colorHex System.String required
Hex color fallback.
fontSize System.Nullable{System.Int32} required
Font size in points.

Returns

The created WordList.

public WordList AddCustomList() #
Returns: WordList

Creates a custom list with no predefined levels for manual configuration.

Returns

The created WordList.

public WordEmbeddedDocument AddEmbeddedDocument(String fileName, Nullable<WordAlternativeFormatImportPartType> type = null) #
Returns: WordEmbeddedDocument

Embeds another document as an alternative format part.

Parameters

fileName System.String requiredposition: 0
Path to the document.
type System.Nullable{OfficeIMO.Word.WordAlternativeFormatImportPartType} = null optionalposition: 1
Optional format part type.

Returns

The created WordEmbeddedDocument.

public WordEmbeddedDocument AddEmbeddedFragment(String htmlContent, WordAlternativeFormatImportPartType type) #
Returns: WordEmbeddedDocument

Embeds HTML content as an alternative format part.

Parameters

htmlContent System.String requiredposition: 0
HTML content to embed.
type OfficeIMO.Word.WordAlternativeFormatImportPartType requiredposition: 1
Format part type.

Returns

The created WordEmbeddedDocument.

public WordEmbeddedDocument AddEmbeddedFragmentAfter(WordParagraph paragraph, String htmlContent, WordAlternativeFormatImportPartType type = Html) #
Returns: WordEmbeddedDocument

Inserts an HTML fragment after the specified paragraph.

Parameters

paragraph OfficeIMO.Word.WordParagraph requiredposition: 0
Paragraph after which the fragment should be inserted.
htmlContent System.String requiredposition: 1
HTML content to insert.
type OfficeIMO.Word.WordAlternativeFormatImportPartType = Html optionalposition: 2
Optional format type of the fragment.

Returns

The created WordEmbeddedDocument.

AddEmbeddedObject 2 overloads
public WordParagraph AddEmbeddedObject(String filePath, String imageFilePath, Nullable<Double> width = null, Nullable<Double> height = null) #
Returns: WordParagraph

Embeds an object with a preview image.

Parameters

filePath System.String requiredposition: 0
Path to the object file.
imageFilePath System.String requiredposition: 1
Preview image path.
width System.Nullable{System.Double} = null optionalposition: 2
Optional width in points.
height System.Nullable{System.Double} = null optionalposition: 3
Optional height in points.

Returns

The paragraph containing the embedded object.

public WordParagraph AddEmbeddedObject(String filePath, WordEmbeddedObjectOptions options) #
Returns: WordParagraph

Embeds an object with custom options.

Parameters

filePath System.String requiredposition: 0
Path to the object file.
options OfficeIMO.Word.WordEmbeddedObjectOptions requiredposition: 1
Embedding options.

Returns

The paragraph containing the embedded object.

public Void AddEndnoteProperties(Nullable<NumberFormatValues> numberingFormat = null, Nullable<EndnotePositionValues> position = null, Nullable<RestartNumberValues> restartNumbering = null, Nullable<Int32> startNumber = null) #
Returns: Void

Adds or updates endnote configuration for the first section.

Parameters

numberingFormat System.Nullable{DocumentFormat.OpenXml.Wordprocessing.NumberFormatValues} = null optionalposition: 0
Numbering format to apply.
position System.Nullable{DocumentFormat.OpenXml.Wordprocessing.EndnotePositionValues} = null optionalposition: 1
Location of endnotes.
restartNumbering System.Nullable{DocumentFormat.OpenXml.Wordprocessing.RestartNumberValues} = null optionalposition: 2
Restart numbering option.
startNumber System.Nullable{System.Int32} = null optionalposition: 3
Starting number.
public WordParagraph AddEquation(String omml) #
Returns: WordParagraph

Inserts an equation specified in OMML format.

Parameters

omml System.String requiredposition: 0
OMML markup for the equation.

Returns

The created WordParagraph.

AddField 3 overloads
public WordParagraph AddField(WordFieldType wordFieldType, Nullable<WordFieldFormat> wordFieldFormat = null, String customFormat = null, Boolean advanced = false, List<String> parameters = null) #
Returns: WordParagraph

Adds a field to the document in a new paragraph.

Parameters

wordFieldType OfficeIMO.Word.WordFieldType requiredposition: 0
Type of field to insert.
wordFieldFormat System.Nullable{OfficeIMO.Word.WordFieldFormat} = null optionalposition: 1
Optional field format.
customFormat System.String = null optionalposition: 2
Custom format string for date or time fields.
advanced System.Boolean = false optionalposition: 3
Whether to use advanced formatting.
parameters System.Collections.Generic.List{System.String} = null optionalposition: 4
Additional switch parameters.

Returns

The created WordParagraph.

public WordParagraph AddField(WordFieldCode fieldCode, Nullable<WordFieldFormat> wordFieldFormat = null, String customFormat = null, Boolean advanced = false) #
Returns: WordParagraph

Adds a field represented by a WordFieldCode to the document in a new paragraph.

Parameters

fieldCode OfficeIMO.Word.WordFieldCode requiredposition: 0
Field code instance describing instructions and switches.
wordFieldFormat System.Nullable{OfficeIMO.Word.WordFieldFormat} = null optionalposition: 1
Optional field format.
customFormat System.String = null optionalposition: 2
Custom format string for date or time fields.
advanced System.Boolean = false optionalposition: 3
Whether to use advanced formatting.

Returns

The created WordParagraph.

public WordParagraph AddField(WordFieldBuilder builder, Boolean advanced = false) #
Returns: WordParagraph

Adds a field built using WordFieldBuilder.

Parameters

builder OfficeIMO.Word.WordFieldBuilder requiredposition: 0
Field builder instance.
advanced System.Boolean = false optionalposition: 1
Whether to use advanced formatting.

Returns

The created WordParagraph.

public Void AddFootnoteProperties(Nullable<NumberFormatValues> numberingFormat = null, Nullable<FootnotePositionValues> position = null, Nullable<RestartNumberValues> restartNumbering = null, Nullable<Int32> startNumber = null) #
Returns: Void

Adds or updates footnote configuration for the first section.

Parameters

numberingFormat System.Nullable{DocumentFormat.OpenXml.Wordprocessing.NumberFormatValues} = null optionalposition: 0
Numbering format to apply.
position System.Nullable{DocumentFormat.OpenXml.Wordprocessing.FootnotePositionValues} = null optionalposition: 1
Location of footnotes.
restartNumbering System.Nullable{DocumentFormat.OpenXml.Wordprocessing.RestartNumberValues} = null optionalposition: 2
Restart numbering option.
startNumber System.Nullable{System.Int32} = null optionalposition: 3
Starting number.
public Void AddHeadersAndFooters() #
Returns: Void

Adds default headers and footers to the document.

public WordParagraph AddHorizontalLine(Nullable<BorderValues> lineType = null, Nullable<Color> color = null, UInt32 size = 12, UInt32 space = 1) #
Returns: WordParagraph

Inserts a horizontal line into the document.

Parameters

lineType System.Nullable{DocumentFormat.OpenXml.Wordprocessing.BorderValues} = null optionalposition: 0
Border style of the line.
color System.Nullable{SixLabors.ImageSharp.Color} = null optionalposition: 1
Line color.
size System.UInt32 = 12 optionalposition: 2
Line width in eighths of a point.
space System.UInt32 = 1 optionalposition: 3
Space above and below the line.

Returns

The paragraph containing the line.

AddHyperLink 2 overloads
public WordImage AddImageFromUrl(String url, Nullable<Double> width = null, Nullable<Double> height = null) #
Returns: WordImage

Downloads an image from the specified URL and inserts it into the document.

Parameters

url System.String requiredposition: 0
URL of the image to download.
width System.Nullable{System.Double} = null optionalposition: 1
Optional width for the image.
height System.Nullable{System.Double} = null optionalposition: 2
Optional height for the image.

Returns

The created WordImage.

public WordImage AddImageVml(String filePathImage, Nullable<Double> width = null, Nullable<Double> height = null) #
Returns: WordImage

Inserts a VML image into the document.

Parameters

filePathImage System.String requiredposition: 0
width System.Nullable{System.Double} = null optionalposition: 1
height System.Nullable{System.Double} = null optionalposition: 2
public WordList AddList(WordListStyle style) #
Returns: WordList

Creates a list using one of the built-in numbering styles. For manually configured lists prefer AddCustomList.

Parameters

style OfficeIMO.Word.WordListStyle requiredposition: 0
public WordList AddListBulleted() #
Returns: WordList

Adds a bulleted list using the default bulleted style.

Returns

The created WordList.

public WordList AddListNumbered() #
Returns: WordList

Adds a numbered list using the default numbering style.

Returns

The created WordList.

AddMacro 2 overloads
public Void AddMacro(String filePath) #
Returns: Void

Adds a VBA project to the document.

Parameters

filePath System.String requiredposition: 0
Path to a vbaProject.bin file.
public Void AddMacro(Byte[] data) #
Returns: Void

Adds a VBA project to the document from bytes.

Parameters

data System.Byte[] requiredposition: 0
VBA project data.
public WordParagraph AddPageBreak() #
Returns: WordParagraph

Inserts a page break into the document.

Returns

The created WordParagraph representing the page break.

public Void AddPageNumbering(Nullable<Int32> startNumber = null, Nullable<NumberFormatValues> format = null) #
Returns: Void

Adds or updates page numbering for the first section.

Parameters

startNumber System.Nullable{System.Int32} = null optionalposition: 0
Starting page number.
format System.Nullable{DocumentFormat.OpenXml.Wordprocessing.NumberFormatValues} = null optionalposition: 1
Number format.
AddParagraph 2 overloads
public WordParagraph AddParagraph(WordParagraph wordParagraph = null) #
Returns: WordParagraph

Appends a paragraph to the document body.

Parameters

wordParagraph OfficeIMO.Word.WordParagraph = null optionalposition: 0
Optional paragraph to append. When null a new paragraph is created.

Returns

The added WordParagraph instance.

public WordParagraph AddParagraph(String text) #
Returns: WordParagraph

Adds a new paragraph containing the specified text.

Parameters

text System.String requiredposition: 0
Text for the paragraph.

Returns

The created WordParagraph.

AddPictureBulletList 2 overloads
public WordList AddPictureBulletList(Stream imageStream, String fileName) #
Returns: WordList

Creates a bullet list where the bullet symbol is provided as an image.

Parameters

imageStream System.IO.Stream requiredposition: 0
Stream containing the image data.
fileName System.String requiredposition: 1
File name used to determine the image type.

Returns

The created WordList.

public WordList AddPictureBulletList(String imagePath) #
Returns: WordList

Creates a bullet list where the bullet symbol is loaded from an image file.

Parameters

imagePath System.String requiredposition: 0
Path to the image file.

Returns

The created WordList.

public WordRepeatingSection AddRepeatingSection(String sectionTitle = null, String alias = null, String tag = null) #
Returns: WordRepeatingSection

Adds a new paragraph with a repeating section content control.

Parameters

sectionTitle System.String = null optionalposition: 0
Optional title of the repeating section.
alias System.String = null optionalposition: 1
Optional alias for the control.
tag System.String = null optionalposition: 2
Optional tag for the control.

Returns

The created WordRepeatingSection.

public WordSection AddSection(Nullable<SectionMarkValues> sectionMark = null) #
Returns: WordSection

Adds a new section to the document.

Parameters

sectionMark System.Nullable{DocumentFormat.OpenXml.Wordprocessing.SectionMarkValues} = null optionalposition: 0
Section break type.

Returns

The created WordSection.

AddShape 2 overloads
public WordShape AddShape(ShapeType shapeType, Double widthPt, Double heightPt, Color fillColor, Color strokeColor, Double strokeWeightPt = 1, Double arcSize = 0.25) #
Returns: WordShape

Adds a basic shape to the document in a new paragraph.

Parameters

shapeType OfficeIMO.Word.ShapeType requiredposition: 0
Type of shape to create.
widthPt System.Double requiredposition: 1
Width in points or line end X.
heightPt System.Double requiredposition: 2
Height in points or line end Y.
fillColor System.String = "#FFFFFF" requiredposition: 3
Fill color in hex format.
strokeColor System.String = "#000000" requiredposition: 4
Stroke color in hex format.
strokeWeightPt System.Double = 1 optionalposition: 5
Stroke weight in points.
arcSize System.Double = 0.25 optionalposition: 6
Corner roundness fraction for rounded rectangles.

Returns

The created WordShape.

AddShape(OfficeIMO.Word.ShapeType shapeType, System.Double widthPt, System.Double heightPt, SixLabors.ImageSharp.Color fillColor, SixLabors.ImageSharp.Color strokeColor, System.Double strokeWeightPt, System.Double arcSize) #

Adds a basic shape to the document using Color values.

Parameters

shapeType OfficeIMO.Word.ShapeType required
widthPt System.Double required
heightPt System.Double required
fillColor SixLabors.ImageSharp.Color required
strokeColor SixLabors.ImageSharp.Color required
strokeWeightPt System.Double required
arcSize System.Double required
AddShapeDrawing 2 overloads
public WordShape AddShapeDrawing(ShapeType shapeType, Double widthPt, Double heightPt) #
Returns: WordShape

Adds a DrawingML shape to the document in a new paragraph.

Parameters

shapeType OfficeIMO.Word.ShapeType requiredposition: 0
Type of shape to create.
widthPt System.Double requiredposition: 1
Width in points.
heightPt System.Double requiredposition: 2
Height in points.
public WordShape AddShapeDrawing(ShapeType shapeType, Double widthPt, Double heightPt, Double leftPt, Double topPt) #
Returns: WordShape

Adds a DrawingML shape anchored at an absolute position on the page in a new paragraph.

Parameters

shapeType OfficeIMO.Word.ShapeType requiredposition: 0
widthPt System.Double requiredposition: 1
heightPt System.Double requiredposition: 2
leftPt System.Double requiredposition: 3
topPt System.Double requiredposition: 4
public WordSmartArt AddSmartArt(SmartArtType type) #
Returns: WordSmartArt

Inserts a SmartArt diagram into the document.

Parameters

type OfficeIMO.Word.SmartArtType requiredposition: 0
Layout type of the SmartArt.

Returns

The created WordSmartArt instance.

public WordStructuredDocumentTag AddStructuredDocumentTag(String text, String alias = null, String tag = null) #
Returns: WordStructuredDocumentTag

Adds a new paragraph with a content control (structured document tag).

Parameters

text System.String requiredposition: 0
Initial text of the control.
alias System.String = null optionalposition: 1
Optional alias for the control.
tag System.String = null optionalposition: 2
Optional tag for the control.

Returns

The created WordStructuredDocumentTag.

AddStyleDefinitions(DocumentFormat.OpenXml.Packaging.StyleDefinitionsPart styleDefinitionsPart, System.Boolean overrideExisting) #

This method is supposed to bring missing elements such as table styles to loaded document

Parameters

styleDefinitionsPart DocumentFormat.OpenXml.Packaging.StyleDefinitionsPart required
The style definitions part to update.
overrideExisting System.Boolean required
When true, existing styles are replaced with the library versions.
public WordTable AddTable(Int32 rows, Int32 columns, WordTableStyle tableStyle = TableGrid) #
Returns: WordTable

Adds a table to the end of the document body.

Parameters

rows System.Int32 requiredposition: 0
Number of rows to create.
columns System.Int32 requiredposition: 1
Number of columns to create.
tableStyle OfficeIMO.Word.WordTableStyle = TableGrid optionalposition: 2
Optional table style to apply.

Returns

The inserted WordTable instance.

public WordTable AddTableFromObjects(IEnumerable<Object> items, WordTableStyle style = TableGrid, Boolean includeHeader = true, Nullable<TableLayoutValues> layout = null) #
Returns: WordTable

Adds a table based on a sequence of objects by projecting properties or dictionary keys into columns.

Parameters

items System.Collections.Generic.IEnumerable{System.Object} requiredposition: 0
Objects to insert into the table.
style OfficeIMO.Word.WordTableStyle = TableGrid optionalposition: 1
Table style to apply.
includeHeader System.Boolean = true optionalposition: 2
Whether to include a header row.
layout System.Nullable{DocumentFormat.OpenXml.Wordprocessing.TableLayoutValues} = null optionalposition: 3
Optional table layout (Autofit or Fixed).

Returns

The created WordTable.

public WordTableOfContent AddTableOfContent(TableOfContentStyle tableOfContentStyle = Template1, Int32 minLevel = 1, Int32 maxLevel = 3) #
Returns: WordTableOfContent

Adds a table of contents to the current document.

Parameters

tableOfContentStyle OfficeIMO.Word.TableOfContentStyle = Template1 optionalposition: 0
Optional style to use when creating the table of contents.
minLevel System.Int32 = 1 optionalposition: 1
Minimum heading level to include (1..9).
maxLevel System.Int32 = 3 optionalposition: 2
Maximum heading level to include (1..9).

Returns

The created WordTableOfContent instance.

public WordList AddTableOfContentList(WordListStyle style) #
Returns: WordList

Creates a list configured for a table of contents.

Parameters

style OfficeIMO.Word.WordListStyle requiredposition: 0
Numbering style to apply.

Returns

The created WordList.

public WordTextBox AddTextBox(String text, WrapTextImage wrapTextImage = Square) #
Returns: WordTextBox

Inserts a text box into the document.

Parameters

text System.String requiredposition: 0
Initial text for the text box.
wrapTextImage OfficeIMO.Word.WrapTextImage = Square optionalposition: 1
Text wrapping option.

Returns

The created WordTextBox.

public WordTextBox AddTextBoxVml(String text) #
Returns: WordTextBox

Inserts a VML text box into the document.

Parameters

text System.String requiredposition: 0
public Void AppendDocument(WordDocument source) #
Returns: Void

Appends the content of another WordDocument to this document.

Parameters

source OfficeIMO.Word.WordDocument requiredposition: 0
The document to append.
public WordFluentDocument AsFluent() #
Returns: WordFluentDocument

Creates a fluent wrapper for this document.

Returns

A new WordFluentDocument instance.

public Int32 CleanupDocument(DocumentCleanupOptions options = All) #
Returns: Int32

This method will combine identical runs in a paragraph. This is useful when you have a paragraph with multiple runs of the same style, that Microsoft Word creates. This feature is *EXPERIMENTAL* and may not work in all cases. It may impact on how your document looks like, please do extensive testing before using this feature.

Parameters

options OfficeIMO.Word.DocumentCleanupOptions = All optionalposition: 0
public WordSection CloneSection(Int32 index) #
Returns: WordSection

Clones the section at the specified index and inserts the clone after it.

Parameters

index System.Int32 requiredposition: 0
Zero based index of the section to clone.

Returns

The cloned WordSection.

CombineIdenticalRuns(DocumentFormat.OpenXml.Wordprocessing.Paragraph paragraph) #

Combines one or multiple Runs having same RunProperties into one Run This is very useful to fix the issue of multiple runs with same formatting that word creates without user noticing.

Parameters

paragraph DocumentFormat.OpenXml.Wordprocessing.Paragraph required
public Void ConvertRevisionsToMarkup() #
Returns: Void

Converts tracked revisions into visible markup by replacing revision elements with formatted runs. Inserted text is underlined and colored blue, while deleted text is displayed with red strikethrough.

CopyPackageProperties(DocumentFormat.OpenXml.Packaging.IPackageProperties src, DocumentFormat.OpenXml.Packaging.IPackageProperties dest) #

Copies package properties. Clone and SaveAs don't actually clone document properties for some reason, so they must be copied manually

Parameters

src DocumentFormat.OpenXml.Packaging.IPackageProperties required
dest DocumentFormat.OpenXml.Packaging.IPackageProperties required
Create 2 overloads
public static WordDocument Create(String filePath = "", Boolean autoSave = false) #
Returns: WordDocument

Create a new WordDocument

Parameters

filePath System.String = "" optionalposition: 0
autoSave System.Boolean = false optionalposition: 1
public static WordDocument Create(Stream stream, WordprocessingDocumentType documentType = Document, Boolean autoSave = false) #
Returns: WordDocument

Create a new WordDocument writing directly to the provided stream.

Parameters

stream System.IO.Stream requiredposition: 0
Destination stream.
documentType DocumentFormat.OpenXml.WordprocessingDocumentType = Document optionalposition: 1
Type of the document.
autoSave System.Boolean = false optionalposition: 2
Whether to save automatically on dispose.

Returns

Instance of WordDocument.

Exceptions

  • ArgumentNullException – Thrown when stream is null.
public static async Task<WordDocument> CreateAsync(String filePath = "", Boolean autoSave = false, CancellationToken cancellationToken = null) #
Returns: Task<WordDocument>

Asynchronously create a new WordDocument.

Parameters

filePath System.String = "" optionalposition: 0
Destination file path.
autoSave System.Boolean = false optionalposition: 1
Enable auto-save on dispose.
cancellationToken System.Threading.CancellationToken = null optionalposition: 2
Cancellation token.

Returns

Created WordDocument.

public WordDocumentSnapshot CreateInspectionSnapshot() #
Returns: WordDocumentSnapshot
public WordListNumbering CreateNumberingDefinition() #
Returns: WordListNumbering

Creates a numbering definition that can be customized and reused.

Returns

The created WordListNumbering.

public WordTable CreateTable(Int32 rows, Int32 columns, WordTableStyle tableStyle = TableGrid) #
Returns: WordTable

Creates a table without inserting it into the document.

Parameters

rows System.Int32 requiredposition: 0
Number of rows to create.
columns System.Int32 requiredposition: 1
Number of columns to create.
tableStyle OfficeIMO.Word.WordTableStyle = TableGrid optionalposition: 2
Optional table style to apply.

Returns

The newly created WordTable.

public virtual Void Dispose() #
Returns: Void

Releases resources associated with this WordDocument instance.

public async Task DisposeAsync() #
Returns: Task

Releases resources associated with the document asynchronously.

EmbedFont 2 overloads
public Void EmbedFont(String fontPath) #
Returns: Void

Embeds a font into the document.

Parameters

fontPath System.String requiredposition: 0
Path to a TrueType/OpenType font file.
public Void EmbedFont(String fontPath, String styleId, String styleName = null) #
Returns: Void

Embeds a font and registers a paragraph style using that font.

Parameters

fontPath System.String requiredposition: 0
Path to a TrueType/OpenType font file.
styleId System.String requiredposition: 1
Style identifier to register.
styleName System.String = null optionalposition: 2
Optional friendly name for the style.
public Byte[] ExtractMacros() #
Returns: Byte[]

Extracts the VBA project as a byte array.

Returns

Byte array with macro content or null when no macros are present.

public List<WordParagraph> Find(String text, StringComparison stringComparison = OrdinalIgnoreCase) #
Returns: List<WordParagraph>

Searches the document for paragraphs containing the specified text.

Parameters

text System.String requiredposition: 0
Text to search for.
stringComparison System.StringComparison = OrdinalIgnoreCase optionalposition: 1
Comparison rules for the search.

Returns

A list of found WordParagraph instances.

FindAndReplace 2 overloads
public Int32 FindAndReplace(String textToFind, String textToReplace, StringComparison stringComparison = OrdinalIgnoreCase) #
Returns: Int32

FindAdnReplace from the whole doc

Parameters

textToFind System.String requiredposition: 0
textToReplace System.String requiredposition: 1
stringComparison System.StringComparison = OrdinalIgnoreCase optionalposition: 2
public static Int32 FindAndReplace(List<WordParagraph> paragraphs, String textToFind, String textToReplace, StringComparison stringComparison = OrdinalIgnoreCase) #
Returns: Int32

FindAdnReplace from the range parparagraphs

Parameters

paragraphs System.Collections.Generic.List{OfficeIMO.Word.WordParagraph} requiredposition: 0
textToFind System.String requiredposition: 1
textToReplace System.String requiredposition: 2
stringComparison System.StringComparison = OrdinalIgnoreCase optionalposition: 3
GenerateDocDefaults() #

Defaults for Word Document

GenerateDocumentSettingsPart1Content(DocumentFormat.OpenXml.Packaging.DocumentSettingsPart documentSettingsPart1) #

Adds default settings for Word Document This is the default from Microsoft Word in Microsoft Office 365

Parameters

documentSettingsPart1 DocumentFormat.OpenXml.Packaging.DocumentSettingsPart required
GenerateWebSettingsPart1Content(DocumentFormat.OpenXml.Packaging.WebSettingsPart webSettingsPart1) #

Adds default settings for WebSettings This is the default from Microsoft Word in Microsoft Office 365

Parameters

webSettingsPart1 DocumentFormat.OpenXml.Packaging.WebSettingsPart required
public WordCheckBox GetCheckBoxByAlias(String alias) #
Returns: WordCheckBox

Retrieves a checkbox control by its alias.

Parameters

alias System.String requiredposition: 0
Alias of the checkbox.

Returns

The matching WordCheckBox or null.

public WordCheckBox GetCheckBoxByTag(String tag) #
Returns: WordCheckBox

Retrieves a checkbox control by its tag value.

Parameters

tag System.String requiredposition: 0
Tag value of the checkbox.

Returns

The matching WordCheckBox or null.

public WordComboBox GetComboBoxByAlias(String alias) #
Returns: WordComboBox

Retrieves a combo box control by its alias.

Parameters

alias System.String requiredposition: 0
public WordComboBox GetComboBoxByTag(String tag) #
Returns: WordComboBox

Retrieves a combo box control by its tag value.

Parameters

tag System.String requiredposition: 0
public WordDatePicker GetDatePickerByAlias(String alias) #
Returns: WordDatePicker

Retrieves a date picker control by its alias.

Parameters

alias System.String requiredposition: 0
Alias of the date picker.

Returns

The matching WordDatePicker or null.

public WordDatePicker GetDatePickerByTag(String tag) #
Returns: WordDatePicker

Retrieves a date picker control by its tag value.

Parameters

tag System.String requiredposition: 0
Tag value of the date picker.

Returns

The matching WordDatePicker or null.

public String GetDocumentVariable(String name) #
Returns: String

Gets the value of a document variable or null if the variable does not exist.

Parameters

name System.String requiredposition: 0
Variable name.
public IReadOnlyDictionary<String, String> GetDocumentVariables() #
Returns: IReadOnlyDictionary<String, String>

Returns a read-only view of all document variables.

public WordDropDownList GetDropDownListByAlias(String alias) #
Returns: WordDropDownList

Retrieves a dropdown list control by its alias.

Parameters

alias System.String requiredposition: 0
Alias of the dropdown list.

Returns

The matching WordDropDownList or null.

public WordDropDownList GetDropDownListByTag(String tag) #
Returns: WordDropDownList

Retrieves a dropdown list control by its tag value.

Parameters

tag System.String requiredposition: 0
Tag value of the dropdown list.

Returns

The matching WordDropDownList or null.

GetFooterForSection 2 overloads
public WordFooter GetFooterForSection(Int32 sectionIndex, HeaderFooterValues type) #
Returns: WordFooter

Returns the footer for a specific section index (use -1 to target the last section).

Parameters

sectionIndex System.Int32 requiredposition: 0
type DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues requiredposition: 1
public WordFooter GetFooterForSection(Int32 sectionIndex = -1) #
Returns: WordFooter

Returns the default footer for a specific section index.

Parameters

sectionIndex System.Int32 = -1 optionalposition: 0
Index of the section or -1 for the last section.
GetHeaderForSection 2 overloads
public WordHeader GetHeaderForSection(Int32 sectionIndex, HeaderFooterValues type) #
Returns: WordHeader

Returns the header for a specific section index (use -1 to target the last section).

Parameters

sectionIndex System.Int32 requiredposition: 0
type DocumentFormat.OpenXml.Wordprocessing.HeaderFooterValues requiredposition: 1
public WordHeader GetHeaderForSection(Int32 sectionIndex = -1) #
Returns: WordHeader

Returns the default header for a specific section index.

Parameters

sectionIndex System.Int32 = -1 optionalposition: 0
Index of the section or -1 for the last section.
public IReadOnlyList<Byte[]> GetImages() #
Returns: IReadOnlyList<Byte[]>

Returns the bytes of all embedded images in the document. Images linked externally are skipped.

public IReadOnlyList<Stream> GetImageStreams() #
Returns: IReadOnlyList<Stream>

Returns streams with data of all embedded images in the document. Images linked externally are skipped.

public WordListNumbering GetNumberingDefinition(Int32 abstractNumberId) #
Returns: WordListNumbering

Retrieves a numbering definition by its identifier.

Parameters

abstractNumberId System.Int32 requiredposition: 0
Identifier of the numbering definition.

Returns

The WordListNumbering if found; otherwise, null.

public WordPictureControl GetPictureControlByAlias(String alias) #
Returns: WordPictureControl

Retrieves a picture control by its alias.

Parameters

alias System.String requiredposition: 0
public WordPictureControl GetPictureControlByTag(String tag) #
Returns: WordPictureControl

Retrieves a picture control by its tag value.

Parameters

tag System.String requiredposition: 0
public WordRepeatingSection GetRepeatingSectionByAlias(String alias) #
Returns: WordRepeatingSection

Retrieves a repeating section control by its alias.

Parameters

alias System.String requiredposition: 0
public WordRepeatingSection GetRepeatingSectionByTag(String tag) #
Returns: WordRepeatingSection

Retrieves a repeating section control by its tag value.

Parameters

tag System.String requiredposition: 0
public WordStructuredDocumentTag GetStructuredDocumentTagByAlias(String alias) #
Returns: WordStructuredDocumentTag

Retrieves a structured document tag by its alias.

Parameters

alias System.String requiredposition: 0
Alias of the control.

Returns

The matching WordStructuredDocumentTag or null.

public WordStructuredDocumentTag GetStructuredDocumentTagByTag(String tag) #
Returns: WordStructuredDocumentTag

Retrieves a structured document tag by its tag value.

Parameters

tag System.String requiredposition: 0
Tag value of the control.

Returns

The matching WordStructuredDocumentTag or null.

HeadingModified() #

Ensures heading edits keep the table-of-contents refresh state aligned with the document settings.

InsertHtmlFragmentAfter(OfficeIMO.Word.WordParagraph paragraph, System.String htmlContent, OfficeIMO.Word.WordAlternativeFormatImportPartType type) #

Inserts an AltChunk containing HTML after the provided paragraph.

Parameters

paragraph OfficeIMO.Word.WordParagraph required
Paragraph to insert after.
htmlContent System.String required
HTML fragment to embed.
type OfficeIMO.Word.WordAlternativeFormatImportPartType required
Format type of the fragment.

Returns

The created WordEmbeddedDocument.

public WordParagraph InsertParagraphAt(Int32 index, WordParagraph paragraph = null) #
Returns: WordParagraph

Inserts a paragraph at the specified index within the body.

Parameters

index System.Int32 requiredposition: 0
Zero-based position at which to insert the paragraph.
paragraph OfficeIMO.Word.WordParagraph = null optionalposition: 1
Optional paragraph to insert. When null a new paragraph is created.

Returns

The inserted WordParagraph.

public WordTable InsertTableAfter(WordParagraph anchor, WordTable table) #
Returns: WordTable

Inserts an existing table after the provided paragraph.

Parameters

anchor OfficeIMO.Word.WordParagraph requiredposition: 0
Paragraph after which the table will be inserted.
table OfficeIMO.Word.WordTable requiredposition: 1
Table instance to insert.

Returns

The inserted WordTable.

Load 2 overloads
public static WordDocument Load(Stream stream, Boolean readOnly = false, Boolean autoSave = false, Boolean overrideStyles = false, OpenSettings openSettings = null) #
Returns: WordDocument

Load WordDocument from filePath

Parameters

filePath System.String requiredposition: 0
readOnly System.Boolean = false optionalposition: 1
autoSave System.Boolean = false optionalposition: 2
overrideStyles System.Boolean = false optionalposition: 3
When true, existing styles are replaced with library versions. Ignored when readOnly is true.
openSettings DocumentFormat.OpenXml.Packaging.OpenSettings = null optionalposition: 4
Optional Open XML settings to control how the package is opened.

Exceptions

  • FileNotFoundException
Load(System.IO.Stream stream, System.Boolean readOnly, System.Boolean autoSave, System.Boolean overrideStyles, DocumentFormat.OpenXml.Packaging.OpenSettings openSettings) #

Load WordDocument from stream

Parameters

stream System.IO.Stream required
readOnly System.Boolean required
autoSave System.Boolean required
overrideStyles System.Boolean required
When true, existing styles are replaced with library versions. Ignored when readOnly is true.
openSettings DocumentFormat.OpenXml.Packaging.OpenSettings required
Optional Open XML settings to control how the package is opened.
public static async Task<WordDocument> LoadAsync(String filePath, Boolean readOnly = false, Boolean autoSave = false, Boolean overrideStyles = false, OpenSettings openSettings = null, CancellationToken cancellationToken = null) #
Returns: Task<WordDocument>

Asynchronously loads a WordDocument from the given file.

Parameters

filePath System.String requiredposition: 0
Path to the file.
readOnly System.Boolean = false optionalposition: 1
Open the document in read-only mode.
autoSave System.Boolean = false optionalposition: 2
Enable auto-save on dispose.
overrideStyles System.Boolean = false optionalposition: 3
When true, existing styles are replaced with library versions. Ignored when readOnly is true.
openSettings DocumentFormat.OpenXml.Packaging.OpenSettings = null optionalposition: 4
Optional Open XML settings to control how the package is opened.
cancellationToken System.Threading.CancellationToken = null optionalposition: 5
Cancellation token.

Returns

Loaded WordDocument instance.

Exceptions

  • FileNotFoundException – Thrown when the file does not exist.
LoadDocument() #

PreSaving function to be called before saving the document

MoveSectionProperties() #

This moves section within body from top to bottom to allow footers/headers to move Needs more work, but this is what Word does all the time

public Void NormalizeTablesForOnline() #
Returns: Void

Walks all tables in body and headers/footers and normalizes their grid/widths so online viewers render them consistently.

Open 2 overloads
public Void Open(Boolean openWord = true) #
Returns: Void

Open WordDocument in Microsoft Word (if Word is present)

Parameters

openWord System.Boolean = true optionalposition: 0
public Void Open(String filePath = "", Boolean openWord = true) #
Returns: Void

Open WordDocument in Microsoft Word (if Word is present)

Parameters

filePath System.String = "" optionalposition: 0
openWord System.Boolean = true optionalposition: 1
RearrangeSectionsAfterLoad() #

Rearrange sections after loading the document

public WordTableOfContent RegenerateTableOfContent() #
Returns: WordTableOfContent

Removes the existing table of contents and creates a new one at the same location.

Returns

The newly created WordTableOfContent.

RejectRevisions 2 overloads
public Void RejectRevisions(String authorName) #
Returns: Void

Reject all revisions by given author

Parameters

authorName System.String requiredposition: 0
public Void RejectRevisions() #
Returns: Void

Reject all revisions in the document

public Void RemoveAllComments() #
Returns: Void

Removes all comments from the document.

RemoveComment 2 overloads
public Void RemoveComment(WordComment comment) #
Returns: Void

Removes comment with the specified id.

Parameters

commentId System.String requiredposition: 0
Id of the comment to remove.
RemoveComment(OfficeIMO.Word.WordComment comment) #

Removes the specified comment from the document.

Parameters

comment OfficeIMO.Word.WordComment required
Comment instance to remove.
public Void RemoveDocumentVariable(String name) #
Returns: Void

Removes the document variable with the specified name if present.

Parameters

name System.String requiredposition: 0
Variable name.
public Void RemoveDocumentVariableAt(Int32 index) #
Returns: Void

Removes the document variable at the specified index.

Parameters

index System.Int32 requiredposition: 0
Zero-based index of the variable to remove.

Exceptions

  • ArgumentOutOfRangeException – Thrown when index is out of range.
public Void RemoveEmbeddedDocument(WordEmbeddedDocument embeddedDocument) #
Returns: Void

Removes an embedded document from the document.

Parameters

embeddedDocument OfficeIMO.Word.WordEmbeddedDocument requiredposition: 0
Embedded document to remove.
public Void RemoveMacro(String name) #
Returns: Void

Removes a single macro module from the document.

Parameters

name System.String requiredposition: 0
Module name to remove.
public Void RemoveMacros() #
Returns: Void

Removes the VBA project from the document.

public Void RemoveSection(Int32 index) #
Returns: Void

Removes the section at the specified index.

Parameters

index System.Int32 requiredposition: 0
Zero based index of the section to remove.
public Void RemoveTableOfContent() #
Returns: Void

Removes the current table of contents from the document if one exists.

RemoveTextSegment(System.Collections.Generic.List{OfficeIMO.Word.WordParagraph} paragraphs, OfficeIMO.Word.WordTextSegment ts) #

Removes text from the paragraphs as specified by the text segment.

Parameters

paragraphs System.Collections.Generic.List{OfficeIMO.Word.WordParagraph} required
Paragraph list to operate on.
ts OfficeIMO.Word.WordTextSegment required
Segment describing the text range to remove.
public Void RemoveWatermark() #
Returns: Void

Removes all watermarks from the document including headers.

ReplaceText(System.Collections.Generic.List{OfficeIMO.Word.WordParagraph} paragraphs, System.String oldText, System.String newText, System.Int32@ count, System.Boolean replace, System.StringComparison stringComparison) #

Replace text inside each paragraph

Parameters

paragraphs System.Collections.Generic.List{OfficeIMO.Word.WordParagraph} required
oldText System.String required
newText System.String required
count System.Int32@ required
replace System.Boolean required
stringComparison System.StringComparison required

Exceptions

  • ArgumentNullException
public Int32 ReplaceTextWithHtmlFragment(String textToFind, String htmlContent, WordAlternativeFormatImportPartType type = Html, StringComparison stringComparison = OrdinalIgnoreCase) #
Returns: Int32

Searches for text in the document and replaces each occurrence with an embedded HTML fragment using AltChunk.

Parameters

textToFind System.String requiredposition: 0
Text to search for.
htmlContent System.String requiredposition: 1
HTML fragment to insert.
type OfficeIMO.Word.WordAlternativeFormatImportPartType = Html optionalposition: 2
Optional format type of the fragment.
stringComparison System.StringComparison = OrdinalIgnoreCase optionalposition: 3
String comparison option for the search.

Returns

The number of replacements performed.

Save 5 overloads
public Void Save(String filePath, Boolean openWord) #
Returns: Void

Save WordDocument to filePath (SaveAs), and open the file in Microsoft Word

Parameters

filePath System.String requiredposition: 0
openWord System.Boolean requiredposition: 1

Exceptions

  • InvalidOperationException
public Void Save() #
Returns: Void

Save WordDocument to where it was open from

public Void Save(Stream outputStream) #
Returns: Void

Save WordDocument to given filePath

Parameters

filePath System.String requiredposition: 0
public Void Save(Boolean openWord) #
Returns: Void

Save WordDocument and open it in Microsoft Word (if Word is present)

Parameters

openWord System.Boolean requiredposition: 0
Save(System.IO.Stream outputStream) #

Save the WordDocument to Stream

Parameters

outputStream System.IO.Stream required

Exceptions

  • InvalidOperationException
SaveAs 2 overloads
public WordDocument SaveAs(String filePath, Boolean openWord = false) #
Returns: WordDocument

Save the document to a new file without modifying FilePath on this instance.

Parameters

filePath System.String requiredposition: 0
Destination path for the cloned document.
openWord System.Boolean = false optionalposition: 1
Whether to open Microsoft Word after saving.

Returns

A new WordDocument loaded from filePath.

public WordDocument SaveAs(Stream outputStream) #
Returns: WordDocument

Clone the document to the specified stream and return a new instance loaded from it.

Parameters

outputStream System.IO.Stream requiredposition: 0
Target stream that must support reading and seeking.

Returns

A new WordDocument loaded from outputStream.

public Byte[] SaveAsByteArray() #
Returns: Byte[]

Save the document to a memory stream and return the stream's byte array.

Returns

A byte array representing the saved Word document.

public MemoryStream SaveAsMemoryStream() #
Returns: MemoryStream

Save the document to a new MemoryStream.

Returns

A memory stream containing the saved document.

SaveAsync 4 overloads
public async Task SaveAsync(String filePath, Boolean openWord, CancellationToken cancellationToken = null) #
Returns: Task

Asynchronously saves the document.

Parameters

filePath System.String requiredposition: 0
Optional path to save to.
openWord System.Boolean requiredposition: 1
Whether to open Word after saving.
cancellationToken System.Threading.CancellationToken = null optionalposition: 2
Cancellation token.
public Task SaveAsync(CancellationToken cancellationToken = null) #
Returns: Task

Asynchronously saves the document to where it was open from.

Parameters

cancellationToken System.Threading.CancellationToken = null optionalposition: 0
Cancellation token.
public Task SaveAsync(Boolean openWord, CancellationToken cancellationToken = null) #
Returns: Task

Asynchronously saves the document to the specified file.

Parameters

filePath System.String requiredposition: 0
The path to save the document to.
cancellationToken System.Threading.CancellationToken = null optionalposition: 1
Cancellation token.
SaveAsync(System.Boolean openWord, System.Threading.CancellationToken cancellationToken) #

Asynchronously saves the document and opens it in Microsoft Word (if Word is present).

Parameters

openWord System.Boolean required
Whether to open Word after saving.
cancellationToken System.Threading.CancellationToken required
Cancellation token.
public Void SaveMacros(String filePath) #
Returns: Void

Saves the VBA project to a file.

Parameters

filePath System.String requiredposition: 0
Destination path.
public Void SetDocumentVariable(String name, String value) #
Returns: Void

Sets the value of a document variable. Creates it if it does not exist.

Parameters

name System.String requiredposition: 0
Variable name.
value System.String requiredposition: 1
Variable value.
public Boolean StyleExists(String styleId) #
Returns: Boolean

Determines whether a paragraph style with the specified identifier exists in the document.

Parameters

styleId System.String requiredposition: 0
The style identifier to look for.

Returns

true if the style exists; otherwise, false.

public Void UpdateFields() #
Returns: Void

Updates page and total page number fields. When a table of contents is present the document is flagged to refresh fields on open so Word can update the TOC.

public List<ValidationErrorInfo> ValidateDocument(FileFormatVersions fileFormatVersions = Microsoft365) #
Returns: List<ValidationErrorInfo>

Validates the document using the specified file format version.

Parameters

fileFormatVersions DocumentFormat.OpenXml.FileFormatVersions = Microsoft365 optionalposition: 0
File format version to validate against.

Returns

List of validation errors.

Properties

public WordTableOfContent TableOfContent { get; } #

Gets the table of contents defined in the document.

public WordCoverPage CoverPage { get; } #

Gets the cover page if one is defined in the document.

public List<WordParagraph> Paragraphs { get; } #

Returns all paragraphs from every section of the document.

public List<WordParagraph> ParagraphsPageBreaks { get; } #

Returns paragraphs that contain page breaks.

public List<WordParagraph> ParagraphsBreaks { get; } #

Returns paragraphs that contain any break elements.

public List<WordParagraph> ParagraphsTabs { get; } #

Returns paragraphs that contain tab characters.

public List<WordParagraph> ParagraphsTabStops { get; } #

Returns paragraphs that define tab stops.

public List<WordParagraph> ParagraphsFields { get; } #

Returns paragraphs that include fields.

public List<WordParagraph> ParagraphsBookmarks { get; } #

Returns paragraphs that contain bookmarks.

public List<WordParagraph> ParagraphsEquations { get; } #

Returns paragraphs containing equations.

public List<WordParagraph> ParagraphsStructuredDocumentTags { get; } #

Returns paragraphs that host structured document tags.

public List<WordParagraph> ParagraphsCheckBoxes { get; } #

Returns paragraphs that contain check boxes.

public List<WordParagraph> ParagraphsDatePickers { get; } #

Returns paragraphs that contain date picker controls.

public List<WordParagraph> ParagraphsDropDownLists { get; } #

Returns paragraphs that contain dropdown list controls.

public List<WordParagraph> ParagraphsComboBoxes { get; } #

Returns paragraphs that contain combo box controls.

public List<WordParagraph> ParagraphsPictureControls { get; } #

Returns paragraphs that contain picture controls.

public List<WordParagraph> ParagraphsRepeatingSections { get; } #

Returns paragraphs that contain repeating section controls.

public List<WordParagraph> ParagraphsCharts { get; } #

Returns paragraphs with embedded charts.

public List<WordParagraph> ParagraphsEndNotes { get; } #

Returns paragraphs referencing endnotes.

public List<WordParagraph> ParagraphsTextBoxes { get; } #

Returns paragraphs that contain text boxes.

public List<WordParagraph> ParagraphsShapes { get; } #

Provides a list of paragraphs that contain shapes.

public List<WordParagraph> ParagraphsSmartArts { get; } #

Returns paragraphs that contain SmartArt diagrams.

public List<WordParagraph> ParagraphsEmbeddedObjects { get; } #

Returns paragraphs containing embedded objects.

public List<WordParagraph> ParagraphsFootNotes { get; } #

Returns paragraphs referencing footnotes.

public List<WordElement> Elements { get; } #

List of all elements in the document from all the sections

public List<WordElement> ElementsByType { get; } #

List of all elements in the document from all the sections by their subtype

public List<WordBreak> PageBreaks { get; } #

List of all PageBreaks in the document from all the sections

public List<WordBreak> Breaks { get; } #

Collection of all break elements (page, column, or text wrapping) found across the document.

public List<WordEndNote> EndNotes { get; } #

Collection of all endnotes referenced throughout the document.

public List<WordFootNote> FootNotes { get; } #

Collection of all footnotes referenced throughout the document.

public List<WordComment> Comments { get; } #

Collection of all comments inserted into the document.

public Boolean HasDocumentVariables { get; } #

Determines whether the document contains any document variables.

public Boolean TrackComments { get; set; } #

Enable or disable tracking of comment changes.

public Boolean TrackChanges { get; set; } #

Enable or disable tracking of all revisions, moves and formatting changes.

public List<WordList> Lists { get; } #

Gets the lists in the document

Value

The lists.

public List<WordBookmark> Bookmarks { get; } #

Provides a list of Bookmarks in the document from all the sections

public List<WordTable> Tables { get; } #

Provides a list of all tables within the document from all the sections, excluding nested tables

public List<WordWatermark> Watermarks { get; } #

Provides a list of all watermarks within the document from all the sections, including watermarks defined in headers.

public List<WordEmbeddedDocument> EmbeddedDocuments { get; } #

Provides a list of all embedded documents within the document.

public List<WordTable> TablesIncludingNestedTables { get; } #

Provides a list of all tables within the document from all the sections, including nested tables

public List<WordParagraph> ParagraphsImages { get; } #

Provides a list of paragraphs that contain Image

public List<WordImage> Images { get; } #

Exposes Images in their Image form for easy access (saving, modifying)

public List<WordEmbeddedObject> EmbeddedObjects { get; } #

Provides a list of all embedded objects within the document.

public List<WordField> Fields { get; } #

Provides a list of all fields within the document.

public List<WordChart> Charts { get; } #

Provides a list of all charts within the document.

public List<WordTextBox> TextBoxes { get; } #

Collection of all text boxes in the document.

public List<WordShape> Shapes { get; } #

Collection of all shapes in the document.

public List<WordSmartArt> SmartArts { get; } #

Collection of all SmartArt diagrams in the document.

public List<WordTabChar> TabChars { get; } #

Collection of tab character elements in the document.

public List<WordStructuredDocumentTag> StructuredDocumentTags { get; } #

Collection of structured document tags in the document.

public List<WordCheckBox> CheckBoxes { get; } #

Collection of all check boxes in the document.

public List<WordDatePicker> DatePickers { get; } #

Collection of all date picker controls in the document.

public List<WordDropDownList> DropDownLists { get; } #

Collection of all dropdown list controls in the document.

public List<WordComboBox> ComboBoxes { get; } #

Collection of all combo box controls in the document.

public List<WordPictureControl> PictureControls { get; } #

Collection of all picture controls in the document.

public List<WordRepeatingSection> RepeatingSections { get; } #

Collection of all repeating section controls in the document.

public List<WordEquation> Equations { get; } #

Collection of all equations in the document.

public String FilePath { get; set; } #

Path to the file backing this document.

OriginalStream #

Original stream where this document was created / loaded from.

public WordCoverPageProperties CoverPageProperties { get; } #

Provides access to the cover page properties custom XML part used by built-in templates.

public Dictionary<String, String> DocumentVariables { get; } #

Collection of document variables accessible via DocVariable fields.

public Dictionary<String, WordBibliographySource> BibliographySources { get; } #

Collection of bibliographic sources used in the document.

public WordDocumentStatistics Statistics { get; set; } #

Provides basic statistics for the document.

public Boolean AutoSave { get; } #

Indicates whether the document is saved automatically.

public Boolean AutoUpdateToc { get; set; } #

When true the table of contents is flagged to update before saving.

public FileAccess FileOpenAccess { get; } #

FileOpenAccess of the document

public WordBackground Background { get; set; } #

Provides access to the document background settings.

public Boolean DocumentIsValid { get; } #

Indicates whether the document passes Open XML validation.

public List<ValidationErrorInfo> DocumentValidationErrors { get; } #

Gets the list of validation errors for the document.

public WordCompatibilitySettings CompatibilitySettings { get; set; } #

Gets or sets compatibility settings for the document.

public WordHeaders Header { get; } #

Gets the headers of the first section.

public WordHeader HeaderDefaultOrCreate { get; } #

Returns the default header of the first section, creating it on demand. Prefer this over Header when you want a non-null result.

public WordHeader HeaderFirstOrCreate { get; } #

Returns the first-page header of the first section, creating it on demand by enabling DifferentFirstPage if necessary.

public WordHeader HeaderEvenOrCreate { get; } #

Returns the even-page header of the first section, creating it on demand by enabling DifferentOddAndEvenPages if necessary.

public WordFooter FooterDefaultOrCreate { get; } #

Returns the default footer of the first section, creating it on demand. Prefer this over Footer when you want a non-null result.

public WordFooter FooterFirstOrCreate { get; } #

Returns the first-page footer of the first section, creating it on demand by enabling DifferentFirstPage if necessary.

public WordFooter FooterEvenOrCreate { get; } #

Returns the even-page footer of the first section, creating it on demand by enabling DifferentOddAndEvenPages if necessary.

public Boolean DifferentFirstPage { get; set; } #

Gets or sets a value indicating whether the first page has different headers and footers.

public Boolean DifferentOddAndEvenPages { get; set; } #

Gets or sets a value indicating whether odd and even pages use different headers and footers.

public Boolean HasMacros { get; } #

Provides basic support for VBA macro projects.

public IReadOnlyList<WordMacro> Macros { get; } #

Gets all macros (module streams) in the document.

public PageOrientationValues PageOrientation { get; set; } #

Gets or sets the orientation of the pages in the first section.

public WordBorders Borders { get; set; } #

Gets or sets the page borders for the first section.

public WordMargins Margins { get; set; } #

Gets or sets the margins for the first section.

public WordPageSizes PageSettings { get; set; } #

Gets or sets the page size settings for the first section.

public FootnoteProperties FootnoteProperties { get; set; } #

Gets or sets the footnote properties for the first section.

public EndnoteProperties EndnoteProperties { get; set; } #

Gets or sets the endnote properties for the first section.

public Boolean RtlGutter { get; set; } #

Gets or sets a value indicating whether the gutter should appear on the right for right-to-left pages in the first section.

public PageNumberType PageNumberType { get; set; } #

Gets or sets the page numbering configuration for the first section.

Fields

public List<WordSection> Sections #

Collection of sections contained in the document.

public WordSettings Settings #

Provides access to document settings.

public ApplicationProperties ApplicationProperties #

Manages application related properties.

public BuiltinDocumentProperties BuiltinDocumentProperties #

Provides access to built-in document properties.

public readonly Dictionary<String, WordCustomProperty> CustomDocumentProperties #

Collection of custom document properties.

public WordprocessingDocument _wordprocessingDocument #

Underlying Open XML word processing document.

public Document _document #

Root document element.

Extension Methods

public static Void AddHeadersAndFooters(WordDocument document) #
Returns: Void

Add default header and footers to section. You can control odd/even/first with DifferentOddAndEventPages/DifferentFirstPage properties.

Parameters

section OfficeIMO.Word.WordSection requiredposition: 0
public static WordParagraph AddParagraphFromXml(WordDocument document, String xml) #
Returns: WordParagraph

Creates a WordParagraph from the provided XML string and appends it to the document.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
Target document.
xml System.String requiredposition: 1
XML string representing a paragraph.

Returns

The inserted WordParagraph.

public static WordFind Find(WordDocument document, Regex regex) #
Returns: WordFind

Searches the document for text matching the specified regular expression.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
Document to search.
regex System.Text.RegularExpressions.Regex requiredposition: 1
Regular expression used for searching.

Returns

A WordFind instance containing all matches.