API Reference
WordDocument
Defines default document settings parts.
Inheritance
- Object
- WordDocument
Constructors
public WordDocument() #Methods
public WordParagraph AddBookmark(String bookmarkName) #WordParagraphInserts a bookmark in a new paragraph.
Parameters
- bookmarkName System.String
- Name of the bookmark.
Returns
The created WordParagraph.
public WordParagraph AddBreak(Nullable<BreakValues> breakType = null) #WordParagraphInserts a break into the document.
Parameters
- breakType System.Nullable{DocumentFormat.OpenXml.Wordprocessing.BreakValues} = null
- 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) #WordChartAdds 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 = ""
- The title.
- roundedCorners System.Boolean = false
- if set to true [rounded corners].
- width System.Int32 = 600
- The width.
- height System.Int32 = 600
- The height.
Returns
WordChart
public WordParagraph AddCitation(String sourceTag) #WordParagraphInserts a citation field referencing the specified source tag.
Parameters
- sourceTag System.String
- Tag of the bibliographic source.
Returns
The created WordParagraph.
public WordChart AddComboChart(String title = "", Boolean roundedCorners = false, Int32 width = 600, Int32 height = 600) #WordChartCreates 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 = ""
- roundedCorners System.Boolean = false
- width System.Int32 = 600
- height System.Int32 = 600
public WordCoverPage AddCoverPage(CoverPageTemplate coverPageTemplate) #WordCoverPageAdds a built-in cover page to the document.
Parameters
- coverPageTemplate OfficeIMO.Word.CoverPageTemplate
- Cover page template to use.
Returns
The created WordCoverPage.
public WordList AddCustomBulletList(Char symbol, String fontName, String colorHex, Nullable<Int32> fontSize = null) #WordListAdds a custom bullet list with formatting options.
Parameters
- symbol System.Char
- Bullet symbol.
- fontName System.String
- Font name for the symbol.
- colorHex System.String
- Hex color of the symbol.
- fontSize System.Nullable{System.Int32} = null
- 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) #WordListAdds a custom bullet list with formatting options.
Parameters
- symbol OfficeIMO.Word.WordBulletSymbol
- Bullet symbol.
- fontName System.String
- Font name for the symbol.
- color System.Nullable{SixLabors.ImageSharp.Color} = null
- Bullet color.
- colorHex System.String = null
- Hex color fallback.
- fontSize System.Nullable{System.Int32} = null
- 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
- Bullet level kind.
- fontName System.String
- Font name for the bullet.
- color System.Nullable{SixLabors.ImageSharp.Color}
- Bullet color.
- colorHex System.String
- Hex color fallback.
- fontSize System.Nullable{System.Int32}
- Font size in points.
Returns
The created WordList.
public WordList AddCustomList() #WordListCreates a custom list with no predefined levels for manual configuration.
Returns
The created WordList.
public WordEmbeddedDocument AddEmbeddedDocument(String fileName, Nullable<WordAlternativeFormatImportPartType> type = null) #WordEmbeddedDocumentEmbeds another document as an alternative format part.
Parameters
- fileName System.String
- Path to the document.
- type System.Nullable{OfficeIMO.Word.WordAlternativeFormatImportPartType} = null
- Optional format part type.
Returns
The created WordEmbeddedDocument.
public WordEmbeddedDocument AddEmbeddedFragment(String htmlContent, WordAlternativeFormatImportPartType type) #WordEmbeddedDocumentEmbeds HTML content as an alternative format part.
Parameters
- htmlContent System.String
- HTML content to embed.
- type OfficeIMO.Word.WordAlternativeFormatImportPartType
- Format part type.
Returns
The created WordEmbeddedDocument.
public WordEmbeddedDocument AddEmbeddedFragmentAfter(WordParagraph paragraph, String htmlContent, WordAlternativeFormatImportPartType type = Html) #WordEmbeddedDocumentInserts an HTML fragment after the specified paragraph.
Parameters
- paragraph OfficeIMO.Word.WordParagraph
- Paragraph after which the fragment should be inserted.
- htmlContent System.String
- HTML content to insert.
- type OfficeIMO.Word.WordAlternativeFormatImportPartType = Html
- Optional format type of the fragment.
Returns
The created WordEmbeddedDocument.
public WordParagraph AddEmbeddedObject(String filePath, String imageFilePath, Nullable<Double> width = null, Nullable<Double> height = null) #WordParagraphEmbeds an object with a preview image.
Parameters
- filePath System.String
- Path to the object file.
- imageFilePath System.String
- Preview image path.
- width System.Nullable{System.Double} = null
- Optional width in points.
- height System.Nullable{System.Double} = null
- Optional height in points.
Returns
The paragraph containing the embedded object.
public WordParagraph AddEmbeddedObject(String filePath, WordEmbeddedObjectOptions options) #WordParagraphEmbeds an object with custom options.
Parameters
- filePath System.String
- Path to the object file.
- options OfficeIMO.Word.WordEmbeddedObjectOptions
- 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) #VoidAdds or updates endnote configuration for the first section.
Parameters
- numberingFormat System.Nullable{DocumentFormat.OpenXml.Wordprocessing.NumberFormatValues} = null
- Numbering format to apply.
- position System.Nullable{DocumentFormat.OpenXml.Wordprocessing.EndnotePositionValues} = null
- Location of endnotes.
- restartNumbering System.Nullable{DocumentFormat.OpenXml.Wordprocessing.RestartNumberValues} = null
- Restart numbering option.
- startNumber System.Nullable{System.Int32} = null
- Starting number.
public WordParagraph AddEquation(String omml) #WordParagraphInserts an equation specified in OMML format.
Parameters
- omml System.String
- OMML markup for the equation.
Returns
The created WordParagraph.
public WordParagraph AddField(WordFieldType wordFieldType, Nullable<WordFieldFormat> wordFieldFormat = null, String customFormat = null, Boolean advanced = false, List<String> parameters = null) #WordParagraphAdds a field to the document in a new paragraph.
Parameters
- wordFieldType OfficeIMO.Word.WordFieldType
- Type of field to insert.
- wordFieldFormat System.Nullable{OfficeIMO.Word.WordFieldFormat} = null
- Optional field format.
- customFormat System.String = null
- Custom format string for date or time fields.
- advanced System.Boolean = false
- Whether to use advanced formatting.
- parameters System.Collections.Generic.List{System.String} = null
- Additional switch parameters.
Returns
The created WordParagraph.
public WordParagraph AddField(WordFieldCode fieldCode, Nullable<WordFieldFormat> wordFieldFormat = null, String customFormat = null, Boolean advanced = false) #WordParagraphAdds a field represented by a WordFieldCode to the document in a new paragraph.
Parameters
- fieldCode OfficeIMO.Word.WordFieldCode
- Field code instance describing instructions and switches.
- wordFieldFormat System.Nullable{OfficeIMO.Word.WordFieldFormat} = null
- Optional field format.
- customFormat System.String = null
- Custom format string for date or time fields.
- advanced System.Boolean = false
- Whether to use advanced formatting.
Returns
The created WordParagraph.
public WordParagraph AddField(WordFieldBuilder builder, Boolean advanced = false) #WordParagraphAdds a field built using WordFieldBuilder.
Parameters
- builder OfficeIMO.Word.WordFieldBuilder
- Field builder instance.
- advanced System.Boolean = false
- 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) #VoidAdds or updates footnote configuration for the first section.
Parameters
- numberingFormat System.Nullable{DocumentFormat.OpenXml.Wordprocessing.NumberFormatValues} = null
- Numbering format to apply.
- position System.Nullable{DocumentFormat.OpenXml.Wordprocessing.FootnotePositionValues} = null
- Location of footnotes.
- restartNumbering System.Nullable{DocumentFormat.OpenXml.Wordprocessing.RestartNumberValues} = null
- Restart numbering option.
- startNumber System.Nullable{System.Int32} = null
- Starting number.
public WordParagraph AddHorizontalLine(Nullable<BorderValues> lineType = null, Nullable<Color> color = null, UInt32 size = 12, UInt32 space = 1) #WordParagraphInserts a horizontal line into the document.
Parameters
- lineType System.Nullable{DocumentFormat.OpenXml.Wordprocessing.BorderValues} = null
- Border style of the line.
- color System.Nullable{SixLabors.ImageSharp.Color} = null
- Line color.
- size System.UInt32 = 12
- Line width in eighths of a point.
- space System.UInt32 = 1
- Space above and below the line.
Returns
The paragraph containing the line.
public WordParagraph AddHyperLink(String text, Uri uri, Boolean addStyle = false, String tooltip = "", Boolean history = true) #WordParagraphAdds a hyperlink pointing to an external URI.
Parameters
- text System.String
- Display text for the hyperlink.
- uri System.Uri
- Target URI.
- addStyle System.Boolean = false
- Whether to apply hyperlink style.
- tooltip System.String = ""
- Tooltip for the hyperlink.
- history System.Boolean = true
- Whether to track link history.
Returns
The created WordParagraph.
public WordParagraph AddHyperLink(String text, String anchor, Boolean addStyle = false, String tooltip = "", Boolean history = true) #WordParagraphAdds an internal hyperlink pointing to a bookmark.
Parameters
- text System.String
- Display text for the hyperlink.
- anchor System.String
- Bookmark anchor.
- addStyle System.Boolean = false
- Whether to apply hyperlink style.
- tooltip System.String = ""
- Tooltip for the hyperlink.
- history System.Boolean = true
- Whether to track link history.
Returns
The created WordParagraph.
public WordImage AddImageFromUrl(String url, Nullable<Double> width = null, Nullable<Double> height = null) #WordImageDownloads an image from the specified URL and inserts it into the document.
Parameters
- url System.String
- URL of the image to download.
- width System.Nullable{System.Double} = null
- Optional width for the image.
- height System.Nullable{System.Double} = null
- Optional height for the image.
Returns
The created WordImage.
public WordImage AddImageVml(String filePathImage, Nullable<Double> width = null, Nullable<Double> height = null) #WordImageInserts a VML image into the document.
Parameters
- filePathImage System.String
- width System.Nullable{System.Double} = null
- height System.Nullable{System.Double} = null
public WordList AddList(WordListStyle style) #WordListCreates a list using one of the built-in numbering styles. For manually configured lists prefer AddCustomList.
Parameters
- style OfficeIMO.Word.WordListStyle
public WordList AddListBulleted() #WordListAdds a bulleted list using the default bulleted style.
Returns
The created WordList.
public WordList AddListNumbered() #WordListAdds a numbered list using the default numbering style.
Returns
The created WordList.
public WordParagraph AddPageBreak() #WordParagraphInserts 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) #VoidAdds or updates page numbering for the first section.
Parameters
- startNumber System.Nullable{System.Int32} = null
- Starting page number.
- format System.Nullable{DocumentFormat.OpenXml.Wordprocessing.NumberFormatValues} = null
- Number format.
public WordParagraph AddParagraph(WordParagraph wordParagraph = null) #WordParagraphAppends a paragraph to the document body.
Parameters
- wordParagraph OfficeIMO.Word.WordParagraph = null
- Optional paragraph to append. When null a new paragraph is created.
Returns
The added WordParagraph instance.
public WordParagraph AddParagraph(String text) #WordParagraphAdds a new paragraph containing the specified text.
Parameters
- text System.String
- Text for the paragraph.
Returns
The created WordParagraph.
public WordList AddPictureBulletList(Stream imageStream, String fileName) #WordListCreates a bullet list where the bullet symbol is provided as an image.
Parameters
- imageStream System.IO.Stream
- Stream containing the image data.
- fileName System.String
- File name used to determine the image type.
Returns
The created WordList.
public WordRepeatingSection AddRepeatingSection(String sectionTitle = null, String alias = null, String tag = null) #WordRepeatingSectionAdds a new paragraph with a repeating section content control.
Parameters
- sectionTitle System.String = null
- Optional title of the repeating section.
- alias System.String = null
- Optional alias for the control.
- tag System.String = null
- Optional tag for the control.
Returns
The created WordRepeatingSection.
public WordSection AddSection(Nullable<SectionMarkValues> sectionMark = null) #WordSectionAdds a new section to the document.
Parameters
- sectionMark System.Nullable{DocumentFormat.OpenXml.Wordprocessing.SectionMarkValues} = null
- Section break type.
Returns
The created WordSection.
public WordShape AddShape(ShapeType shapeType, Double widthPt, Double heightPt, Color fillColor, Color strokeColor, Double strokeWeightPt = 1, Double arcSize = 0.25) #WordShapeAdds a basic shape to the document in a new paragraph.
Parameters
- shapeType OfficeIMO.Word.ShapeType
- Type of shape to create.
- widthPt System.Double
- Width in points or line end X.
- heightPt System.Double
- Height in points or line end Y.
- fillColor System.String = "#FFFFFF"
- Fill color in hex format.
- strokeColor System.String = "#000000"
- Stroke color in hex format.
- strokeWeightPt System.Double = 1
- Stroke weight in points.
- arcSize System.Double = 0.25
- 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
- widthPt System.Double
- heightPt System.Double
- fillColor SixLabors.ImageSharp.Color
- strokeColor SixLabors.ImageSharp.Color
- strokeWeightPt System.Double
- arcSize System.Double
public WordShape AddShapeDrawing(ShapeType shapeType, Double widthPt, Double heightPt) #WordShapeAdds a DrawingML shape to the document in a new paragraph.
Parameters
- shapeType OfficeIMO.Word.ShapeType
- Type of shape to create.
- widthPt System.Double
- Width in points.
- heightPt System.Double
- Height in points.
public WordShape AddShapeDrawing(ShapeType shapeType, Double widthPt, Double heightPt, Double leftPt, Double topPt) #WordShapeAdds a DrawingML shape anchored at an absolute position on the page in a new paragraph.
Parameters
- shapeType OfficeIMO.Word.ShapeType
- widthPt System.Double
- heightPt System.Double
- leftPt System.Double
- topPt System.Double
public WordSmartArt AddSmartArt(SmartArtType type) #WordSmartArtInserts a SmartArt diagram into the document.
Parameters
- type OfficeIMO.Word.SmartArtType
- Layout type of the SmartArt.
Returns
The created WordSmartArt instance.
public WordStructuredDocumentTag AddStructuredDocumentTag(String text, String alias = null, String tag = null) #WordStructuredDocumentTagAdds a new paragraph with a content control (structured document tag).
Parameters
- text System.String
- Initial text of the control.
- alias System.String = null
- Optional alias for the control.
- tag System.String = null
- 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
- The style definitions part to update.
- overrideExisting System.Boolean
- When true, existing styles are replaced with the library versions.
public WordTable AddTable(Int32 rows, Int32 columns, WordTableStyle tableStyle = TableGrid) #WordTableAdds a table to the end of the document body.
Parameters
- rows System.Int32
- Number of rows to create.
- columns System.Int32
- Number of columns to create.
- tableStyle OfficeIMO.Word.WordTableStyle = TableGrid
- 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) #WordTableAdds a table based on a sequence of objects by projecting properties or dictionary keys into columns.
Parameters
- items System.Collections.Generic.IEnumerable{System.Object}
- Objects to insert into the table.
- style OfficeIMO.Word.WordTableStyle = TableGrid
- Table style to apply.
- includeHeader System.Boolean = true
- Whether to include a header row.
- layout System.Nullable{DocumentFormat.OpenXml.Wordprocessing.TableLayoutValues} = null
- Optional table layout (Autofit or Fixed).
Returns
The created WordTable.
public WordTableOfContent AddTableOfContent(TableOfContentStyle tableOfContentStyle = Template1, Int32 minLevel = 1, Int32 maxLevel = 3) #WordTableOfContentAdds a table of contents to the current document.
Parameters
- tableOfContentStyle OfficeIMO.Word.TableOfContentStyle = Template1
- Optional style to use when creating the table of contents.
- minLevel System.Int32 = 1
- Minimum heading level to include (1..9).
- maxLevel System.Int32 = 3
- Maximum heading level to include (1..9).
Returns
The created WordTableOfContent instance.
public WordList AddTableOfContentList(WordListStyle style) #WordListCreates a list configured for a table of contents.
Parameters
- style OfficeIMO.Word.WordListStyle
- Numbering style to apply.
Returns
The created WordList.
public WordTextBox AddTextBox(String text, WrapTextImage wrapTextImage = Square) #WordTextBoxInserts a text box into the document.
Parameters
- text System.String
- Initial text for the text box.
- wrapTextImage OfficeIMO.Word.WrapTextImage = Square
- Text wrapping option.
Returns
The created WordTextBox.
public WordTextBox AddTextBoxVml(String text) #WordTextBoxInserts a VML text box into the document.
Parameters
- text System.String
public Void AppendDocument(WordDocument source) #VoidAppends the content of another WordDocument to this document.
Parameters
- source OfficeIMO.Word.WordDocument
- The document to append.
public WordFluentDocument AsFluent() #WordFluentDocumentCreates a fluent wrapper for this document.
Returns
A new WordFluentDocument instance.
public Int32 CleanupDocument(DocumentCleanupOptions options = All) #Int32This 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
public WordSection CloneSection(Int32 index) #WordSectionClones the section at the specified index and inserts the clone after it.
Parameters
- index System.Int32
- 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
public Void ConvertRevisionsToMarkup() #VoidConverts 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
- dest DocumentFormat.OpenXml.Packaging.IPackageProperties
public static WordDocument Create(String filePath = "", Boolean autoSave = false) #WordDocumentCreate a new WordDocument
Parameters
- filePath System.String = ""
- autoSave System.Boolean = false
public static WordDocument Create(Stream stream, WordprocessingDocumentType documentType = Document, Boolean autoSave = false) #WordDocumentCreate a new WordDocument writing directly to the provided stream.
Parameters
- stream System.IO.Stream
- Destination stream.
- documentType DocumentFormat.OpenXml.WordprocessingDocumentType = Document
- Type of the document.
- autoSave System.Boolean = false
- 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) #Task<WordDocument>Asynchronously create a new WordDocument.
Parameters
- filePath System.String = ""
- Destination file path.
- autoSave System.Boolean = false
- Enable auto-save on dispose.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
Returns
Created WordDocument.
public WordDocumentSnapshot CreateInspectionSnapshot() #WordDocumentSnapshotpublic WordListNumbering CreateNumberingDefinition() #WordListNumberingCreates a numbering definition that can be customized and reused.
Returns
The created WordListNumbering.
public WordTable CreateTable(Int32 rows, Int32 columns, WordTableStyle tableStyle = TableGrid) #WordTableCreates a table without inserting it into the document.
Parameters
- rows System.Int32
- Number of rows to create.
- columns System.Int32
- Number of columns to create.
- tableStyle OfficeIMO.Word.WordTableStyle = TableGrid
- Optional table style to apply.
Returns
The newly created WordTable.
public virtual Void Dispose() #VoidReleases resources associated with this WordDocument instance.
public async Task DisposeAsync() #TaskReleases resources associated with the document asynchronously.
public Void EmbedFont(String fontPath) #VoidEmbeds a font into the document.
Parameters
- fontPath System.String
- Path to a TrueType/OpenType font file.
public Void EmbedFont(String fontPath, String styleId, String styleName = null) #VoidEmbeds a font and registers a paragraph style using that font.
Parameters
- fontPath System.String
- Path to a TrueType/OpenType font file.
- styleId System.String
- Style identifier to register.
- styleName System.String = null
- Optional friendly name for the style.
public Byte[] ExtractMacros() #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) #List<WordParagraph>Searches the document for paragraphs containing the specified text.
Parameters
- text System.String
- Text to search for.
- stringComparison System.StringComparison = OrdinalIgnoreCase
- Comparison rules for the search.
Returns
A list of found WordParagraph instances.
public Int32 FindAndReplace(String textToFind, String textToReplace, StringComparison stringComparison = OrdinalIgnoreCase) #Int32FindAdnReplace from the whole doc
Parameters
- textToFind System.String
- textToReplace System.String
- stringComparison System.StringComparison = OrdinalIgnoreCase
public static Int32 FindAndReplace(List<WordParagraph> paragraphs, String textToFind, String textToReplace, StringComparison stringComparison = OrdinalIgnoreCase) #Int32FindAdnReplace from the range parparagraphs
Parameters
- paragraphs System.Collections.Generic.List{OfficeIMO.Word.WordParagraph}
- textToFind System.String
- textToReplace System.String
- stringComparison System.StringComparison = OrdinalIgnoreCase
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
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
public WordCheckBox GetCheckBoxByAlias(String alias) #WordCheckBoxRetrieves a checkbox control by its alias.
Parameters
- alias System.String
- Alias of the checkbox.
Returns
The matching WordCheckBox or null.
public WordCheckBox GetCheckBoxByTag(String tag) #WordCheckBoxRetrieves a checkbox control by its tag value.
Parameters
- tag System.String
- Tag value of the checkbox.
Returns
The matching WordCheckBox or null.
public WordComboBox GetComboBoxByAlias(String alias) #WordComboBoxRetrieves a combo box control by its alias.
Parameters
- alias System.String
public WordComboBox GetComboBoxByTag(String tag) #WordComboBoxRetrieves a combo box control by its tag value.
Parameters
- tag System.String
public WordDatePicker GetDatePickerByAlias(String alias) #WordDatePickerRetrieves a date picker control by its alias.
Parameters
- alias System.String
- Alias of the date picker.
Returns
The matching WordDatePicker or null.
public WordDatePicker GetDatePickerByTag(String tag) #WordDatePickerRetrieves a date picker control by its tag value.
Parameters
- tag System.String
- Tag value of the date picker.
Returns
The matching WordDatePicker or null.
public String GetDocumentVariable(String name) #StringGets the value of a document variable or null if the variable does not exist.
Parameters
- name System.String
- Variable name.
public IReadOnlyDictionary<String, String> GetDocumentVariables() #IReadOnlyDictionary<String, String>Returns a read-only view of all document variables.
public WordDropDownList GetDropDownListByAlias(String alias) #WordDropDownListRetrieves a dropdown list control by its alias.
Parameters
- alias System.String
- Alias of the dropdown list.
Returns
The matching WordDropDownList or null.
public WordDropDownList GetDropDownListByTag(String tag) #WordDropDownListRetrieves a dropdown list control by its tag value.
Parameters
- tag System.String
- Tag value of the dropdown list.
Returns
The matching WordDropDownList or null.
public WordHeader GetHeaderForSection(Int32 sectionIndex = -1) #WordHeaderReturns the default header for a specific section index.
Parameters
- sectionIndex System.Int32 = -1
- Index of the section or -1 for the last section.
public IReadOnlyList<Byte[]> GetImages() #IReadOnlyList<Byte[]>Returns the bytes of all embedded images in the document. Images linked externally are skipped.
public IReadOnlyList<Stream> GetImageStreams() #IReadOnlyList<Stream>Returns streams with data of all embedded images in the document. Images linked externally are skipped.
public WordListNumbering GetNumberingDefinition(Int32 abstractNumberId) #WordListNumberingRetrieves a numbering definition by its identifier.
Parameters
- abstractNumberId System.Int32
- Identifier of the numbering definition.
Returns
The WordListNumbering if found; otherwise, null.
public WordPictureControl GetPictureControlByAlias(String alias) #WordPictureControlRetrieves a picture control by its alias.
Parameters
- alias System.String
public WordPictureControl GetPictureControlByTag(String tag) #WordPictureControlRetrieves a picture control by its tag value.
Parameters
- tag System.String
public WordRepeatingSection GetRepeatingSectionByAlias(String alias) #WordRepeatingSectionRetrieves a repeating section control by its alias.
Parameters
- alias System.String
public WordRepeatingSection GetRepeatingSectionByTag(String tag) #WordRepeatingSectionRetrieves a repeating section control by its tag value.
Parameters
- tag System.String
public WordStructuredDocumentTag GetStructuredDocumentTagByAlias(String alias) #WordStructuredDocumentTagRetrieves a structured document tag by its alias.
Parameters
- alias System.String
- Alias of the control.
Returns
The matching WordStructuredDocumentTag or null.
public WordStructuredDocumentTag GetStructuredDocumentTagByTag(String tag) #WordStructuredDocumentTagRetrieves a structured document tag by its tag value.
Parameters
- tag System.String
- 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
- Paragraph to insert after.
- htmlContent System.String
- HTML fragment to embed.
- type OfficeIMO.Word.WordAlternativeFormatImportPartType
- Format type of the fragment.
Returns
The created WordEmbeddedDocument.
public WordParagraph InsertParagraphAt(Int32 index, WordParagraph paragraph = null) #WordParagraphInserts a paragraph at the specified index within the body.
Parameters
- index System.Int32
- Zero-based position at which to insert the paragraph.
- paragraph OfficeIMO.Word.WordParagraph = null
- Optional paragraph to insert. When null a new paragraph is created.
Returns
The inserted WordParagraph.
public WordTable InsertTableAfter(WordParagraph anchor, WordTable table) #WordTableInserts an existing table after the provided paragraph.
Parameters
- anchor OfficeIMO.Word.WordParagraph
- Paragraph after which the table will be inserted.
- table OfficeIMO.Word.WordTable
- Table instance to insert.
Returns
The inserted WordTable.
public static WordDocument Load(Stream stream, Boolean readOnly = false, Boolean autoSave = false, Boolean overrideStyles = false, OpenSettings openSettings = null) #WordDocumentLoad WordDocument from filePath
Parameters
- filePath System.String
- readOnly System.Boolean = false
- autoSave System.Boolean = false
- overrideStyles System.Boolean = false
- When true, existing styles are replaced with library versions. Ignored when readOnly is true.
- openSettings DocumentFormat.OpenXml.Packaging.OpenSettings = null
- 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
- readOnly System.Boolean
- autoSave System.Boolean
- overrideStyles System.Boolean
- When true, existing styles are replaced with library versions. Ignored when readOnly is true.
- openSettings DocumentFormat.OpenXml.Packaging.OpenSettings
- 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) #Task<WordDocument>Asynchronously loads a WordDocument from the given file.
Parameters
- filePath System.String
- Path to the file.
- readOnly System.Boolean = false
- Open the document in read-only mode.
- autoSave System.Boolean = false
- Enable auto-save on dispose.
- overrideStyles System.Boolean = false
- When true, existing styles are replaced with library versions. Ignored when readOnly is true.
- openSettings DocumentFormat.OpenXml.Packaging.OpenSettings = null
- Optional Open XML settings to control how the package is opened.
- cancellationToken System.Threading.CancellationToken = null
- 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() #VoidWalks all tables in body and headers/footers and normalizes their grid/widths so online viewers render them consistently.
public Void Open(Boolean openWord = true) #VoidOpen WordDocument in Microsoft Word (if Word is present)
Parameters
- openWord System.Boolean = true
public Void Open(String filePath = "", Boolean openWord = true) #VoidOpen WordDocument in Microsoft Word (if Word is present)
Parameters
- filePath System.String = ""
- openWord System.Boolean = true
RearrangeSectionsAfterLoad() #Rearrange sections after loading the document
public WordTableOfContent RegenerateTableOfContent() #WordTableOfContentRemoves the existing table of contents and creates a new one at the same location.
Returns
The newly created WordTableOfContent.
public Void RemoveComment(WordComment comment) #VoidRemoves comment with the specified id.
Parameters
- commentId System.String
- Id of the comment to remove.
RemoveComment(OfficeIMO.Word.WordComment comment) #Removes the specified comment from the document.
Parameters
- comment OfficeIMO.Word.WordComment
- Comment instance to remove.
public Void RemoveDocumentVariable(String name) #VoidRemoves the document variable with the specified name if present.
Parameters
- name System.String
- Variable name.
public Void RemoveDocumentVariableAt(Int32 index) #VoidRemoves the document variable at the specified index.
Parameters
- index System.Int32
- Zero-based index of the variable to remove.
Exceptions
ArgumentOutOfRangeException– Thrown when index is out of range.
public Void RemoveEmbeddedDocument(WordEmbeddedDocument embeddedDocument) #VoidRemoves an embedded document from the document.
Parameters
- embeddedDocument OfficeIMO.Word.WordEmbeddedDocument
- Embedded document to remove.
public Void RemoveMacro(String name) #VoidRemoves a single macro module from the document.
Parameters
- name System.String
- Module name to remove.
public Void RemoveSection(Int32 index) #VoidRemoves the section at the specified index.
Parameters
- index System.Int32
- Zero based index of the section to remove.
public Void RemoveTableOfContent() #VoidRemoves 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}
- Paragraph list to operate on.
- ts OfficeIMO.Word.WordTextSegment
- Segment describing the text range to remove.
public Void RemoveWatermark() #VoidRemoves 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}
- oldText System.String
- newText System.String
- count System.Int32@
- replace System.Boolean
- stringComparison System.StringComparison
Exceptions
ArgumentNullException
public Int32 ReplaceTextWithHtmlFragment(String textToFind, String htmlContent, WordAlternativeFormatImportPartType type = Html, StringComparison stringComparison = OrdinalIgnoreCase) #Int32Searches for text in the document and replaces each occurrence with an embedded HTML fragment using AltChunk.
Parameters
- textToFind System.String
- Text to search for.
- htmlContent System.String
- HTML fragment to insert.
- type OfficeIMO.Word.WordAlternativeFormatImportPartType = Html
- Optional format type of the fragment.
- stringComparison System.StringComparison = OrdinalIgnoreCase
- String comparison option for the search.
Returns
The number of replacements performed.
public Void Save(String filePath, Boolean openWord) #VoidSave WordDocument to filePath (SaveAs), and open the file in Microsoft Word
Parameters
- filePath System.String
- openWord System.Boolean
Exceptions
InvalidOperationException
public Void Save(Stream outputStream) #VoidSave WordDocument to given filePath
Parameters
- filePath System.String
public Void Save(Boolean openWord) #VoidSave WordDocument and open it in Microsoft Word (if Word is present)
Parameters
- openWord System.Boolean
Save(System.IO.Stream outputStream) #Save the WordDocument to Stream
Parameters
- outputStream System.IO.Stream
Exceptions
InvalidOperationException
public WordDocument SaveAs(String filePath, Boolean openWord = false) #WordDocumentSave the document to a new file without modifying FilePath on this instance.
Parameters
- filePath System.String
- Destination path for the cloned document.
- openWord System.Boolean = false
- Whether to open Microsoft Word after saving.
Returns
A new WordDocument loaded from filePath.
public WordDocument SaveAs(Stream outputStream) #WordDocumentClone the document to the specified stream and return a new instance loaded from it.
Parameters
- outputStream System.IO.Stream
- Target stream that must support reading and seeking.
Returns
A new WordDocument loaded from outputStream.
public Byte[] SaveAsByteArray() #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() #MemoryStreamSave the document to a new MemoryStream.
Returns
A memory stream containing the saved document.
public async Task SaveAsync(String filePath, Boolean openWord, CancellationToken cancellationToken = null) #TaskAsynchronously saves the document.
Parameters
- filePath System.String
- Optional path to save to.
- openWord System.Boolean
- Whether to open Word after saving.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
public Task SaveAsync(CancellationToken cancellationToken = null) #TaskAsynchronously saves the document to where it was open from.
Parameters
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
public Task SaveAsync(Boolean openWord, CancellationToken cancellationToken = null) #TaskAsynchronously saves the document to the specified file.
Parameters
- filePath System.String
- The path to save the document to.
- cancellationToken System.Threading.CancellationToken = null
- 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
- Whether to open Word after saving.
- cancellationToken System.Threading.CancellationToken
- Cancellation token.
public Void SaveMacros(String filePath) #VoidSaves the VBA project to a file.
Parameters
- filePath System.String
- Destination path.
public Void SetDocumentVariable(String name, String value) #VoidSets the value of a document variable. Creates it if it does not exist.
Parameters
- name System.String
- Variable name.
- value System.String
- Variable value.
public Boolean StyleExists(String styleId) #BooleanDetermines whether a paragraph style with the specified identifier exists in the document.
Parameters
- styleId System.String
- The style identifier to look for.
Returns
true if the style exists; otherwise, false.
public Void UpdateFields() #VoidUpdates 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) #List<ValidationErrorInfo>Validates the document using the specified file format version.
Parameters
- fileFormatVersions DocumentFormat.OpenXml.FileFormatVersions = Microsoft365
- File format version to validate against.
Returns
List of validation errors.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
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> ParagraphsHyperLinks { get; } #Returns paragraphs that include hyperlinks.
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<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<WordHyperLink> HyperLinks { get; } #Collection of all hyperlinks in 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 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 WordParagraph AddParagraphFromXml(WordDocument document, String xml) #WordParagraphCreates a WordParagraph from the provided XML string and appends it to the document.
Parameters
- document OfficeIMO.Word.WordDocument
- Target document.
- xml System.String
- XML string representing a paragraph.
Returns
The inserted WordParagraph.
public static WordFind Find(WordDocument document, Regex regex) #WordFindSearches the document for text matching the specified regular expression.
Parameters
- document OfficeIMO.Word.WordDocument
- Document to search.
- regex System.Text.RegularExpressions.Regex
- Regular expression used for searching.
Returns
A WordFind instance containing all matches.