WordDocument
OfficeIMO.Word
Provides functionality for creating, loading and manipulating Word documents.
Inheritance
- object
- WordDocument
Usage
Explore 71 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 10
- Method LegacyWordImportResult.RequireValue
- Property LegacyWordImportResult.Value
- Method WordDocument.ApplyTheme
- Method WordDocument.Create
- Method WordDocument.Load
- Method WordDocument.LoadAsync
- Method WordDocument.SplitByHeading
- Method WordDocument.SplitBySection
- Method WordDocumentComparer.Compare
- Property WordMacroProject.Document
Accepted by parameters 61
- Constructor WordApplicationProperties.WordApplicationProperties
- Constructor WordBackground.WordBackground
- Constructor WordBuiltinDocumentProperties.WordBuiltinDocumentProperties
- Constructor WordChart.WordChart
- Method WordComment.Create
- Method WordComment.GetAllComments
- Constructor WordCompatibilitySettings.WordCompatibilitySettings
- Constructor WordCoverPage.WordCoverPage
- Constructor WordCoverPageProperties.WordCoverPageProperties
- Constructor WordCustomProperties.WordCustomProperties
- Extension method WordDocument.AddParagraphFromXml
- Method WordDocument.AppendDocument
- Method WordDocument.MarkIndexEntriesFromConcordance
- Method WordDocumentComparer.CompareStructure
- Method WordDocumentComparer.CompareStructure
- Method WordDocumentComparer.CreateRedlineDocument
- Method WordDocumentComparer.CreateRedlineDocument
- Constructor WordDocumentStatistics.WordDocumentStatistics
- Constructor WordDocumentVariables.WordDocumentVariables
- Constructor WordEmbeddedDocument.WordEmbeddedDocument
- Constructor WordEmbeddedObject.WordEmbeddedObject
- Method WordFooter.RemoveFooters
- Method WordHeader.RemoveHeaders
- Constructor WordList.WordList
- Method WordList.AddCustomBulletList
- Method WordList.AddCustomList
- Method WordList.AddPictureBulletList
- Method WordListNumbering.CreateNumberingDefinition
- Method WordListNumbering.GetNumberingDefinition
- Method WordMailMerge.Execute
- Method WordMailMerge.ExecuteConditionalBlocks
- Method WordMailMerge.ExecuteContentControlDataBindings
- Method WordMailMerge.ExecuteRepeatingBlockRegions
- Method WordMailMerge.ExecuteRepeatingBlocks
- Method WordMailMerge.ExecuteWithReport
- Method WordMailMerge.InspectTemplate
- Method WordMailMerge.PreflightTemplate
- Method WordMailMerge.RefreshContentControlDataBindings
- Method WordMailMerge.ValidateTemplate
- Constructor WordMargins.WordMargins
- Constructor WordPageNumber.WordPageNumber
- Constructor WordPageSizes.WordPageSizes
- Method WordPaperStyle.AddCallout
- Method WordPaperStyle.AddCountTable
- Method WordPaperStyle.AddCover
- Method WordPaperStyle.AddKeyValueTable
- Method WordPaperStyle.AddMetrics
- Method WordPaperStyle.AddNote
- Method WordPaperStyle.AddPageChrome
- Method WordPaperStyle.ApplyTypography
- Constructor WordParagraph.WordParagraph
- Constructor WordSettings.WordSettings
- Method WordStyleCollection.Import
- Method WordTable.Create
- Constructor WordTableOfContent.WordTableOfContent
- Constructor WordTableRow.WordTableRow
- Method WordTemplate.Apply
- Constructor WordTextBox.WordTextBox
- Method WordTheme.Import
- Constructor WordWatermark.WordWatermark
- Method WordXmlExtensions.AddParagraphFromXml
Examples
using OfficeIMO.Word;
using var document = WordDocument.Create();
document.AddParagraph("Hello from OfficeIMO.");
document.Save("hello.docx");Constructors
public WordDocument() #Methods
public void AcceptRevisions(string authorName) #Given author name, accept all revisions by given Author.
Parameters
- authorName string
- Author whose revisions should be accepted.
public WordRevisionOperationReport AcceptRevisions(WordRevisionFilter filter) #Accepts revisions that match the provided filter and returns a deterministic operation report.
Parameters
- filter OfficeIMO.Word.WordRevisionFilter
- Filter describing revisions to accept.
Returns
WordRevisionOperationReportpublic WordRevisionOperationReport AcceptRevisionsInParagraph(WordParagraph paragraph, WordRevisionFilter? filter = null) #Accepts revisions inside the specified paragraph.
Parameters
- paragraph OfficeIMO.Word.WordParagraph
- Paragraph that scopes the operation.
- filter OfficeIMO.Word.WordRevisionFilter? = null
- Optional additional filter.
Returns
WordRevisionOperationReportpublic WordBookmark AddBookmark(string bookmarkName) #Inserts a bookmark in a new paragraph.
Parameters
- bookmarkName string
- Name of the bookmark.
public WordParagraph AddBreak(WordBreakType? breakType = null) #Inserts a break into the document.
Parameters
- breakType OfficeIMO.Word.WordBreakType? = null
- Type of break to insert.
public WordParagraph AddCallout(OfficeCalloutKind kind, string title, string body, OfficeTheme? theme = null) #Adds a shaded callout title and body, returning its title paragraph.
Parameters
- kind OfficeIMO.OfficeCalloutKind
- title string
- body string
- theme OfficeIMO.OfficeTheme? = null
Returns
WordParagraphpublic IReadOnlyList<WordComment> AddCellComments(IEnumerable<WordCellComment> comments, CancellationToken cancellationToken = default) #Adds root comments across body table cells, allocating identities and saving comment parts once per batch.
Parameters
- comments System.Collections.Generic.IEnumerable<OfficeIMO.Word.WordCellComment>
- cancellationToken System.Threading.CancellationToken = default
Returns
IReadOnlyList<WordComment>public WordChart AddChart(string title = "", bool roundedCorners = false, OfficeLength? width = null, OfficeLength? height = null) #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 string = ""
- The title.
- roundedCorners bool = false
- if set to true [rounded corners].
- width OfficeIMO.OfficeLength? = null
- The width.
- height OfficeIMO.OfficeLength? = null
- The height.
public WordChart AddChart(OfficeChartType chartKind, OfficeChartData data) #Adds an editable native chart with the format's default title, size and placement.
Parameters
- chartKind OfficeIMO.OfficeChartType
- data OfficeIMO.Drawing.OfficeChartData
Returns
WordChartpublic WordChart AddChart(OfficeChartType chartKind, OfficeChartData data, OfficeChartOptions? options) #Creates an editable native chart and embedded worksheet from the shared OfficeIMO chart contract.
Parameters
- chartKind OfficeIMO.OfficeChartType
- Default chart family, with optional per-series kinds for supported combinations.
- data OfficeIMO.Drawing.OfficeChartData
- Categories, series, and their supported appearance.
- options OfficeIMO.OfficeChartOptions?
- Optional title, physical size and Word frame options. The default size is 600 by 600 pixels.
public WordChart AddChart<T>(OfficeChartType type, IEnumerable<T?> data, string category, params string[] series) #Adds an editable native chart using property names, including names supplied with nameof.
Type Parameters
- T
Parameters
- type OfficeIMO.OfficeChartType
- data System.Collections.Generic.IEnumerable<T?>
- category string
- series string[]
Returns
WordChartpublic WordChart AddChart<T>(OfficeChartType type, IEnumerable<T?> data, string category, OfficeChartOptions? options, params string[] series) #Adds an editable native chart using property names and shared or format-specific options.
Type Parameters
- T
Parameters
- type OfficeIMO.OfficeChartType
- data System.Collections.Generic.IEnumerable<T?>
- category string
- options OfficeIMO.OfficeChartOptions?
- series string[]
Returns
WordChartpublic WordChart AddChart<T, TCategory>(OfficeChartType type, IEnumerable<T?> data, Func<T?, TCategory?> category, params OfficeSeries[] series) #Adds an editable native chart from typed category data and numeric series.
Type Parameters
- T
- TCategory
Parameters
- type OfficeIMO.OfficeChartType
- data System.Collections.Generic.IEnumerable<T?>
- category System.Func<T?, TCategory?>
- series OfficeIMO.OfficeSeries[]
Returns
WordChartpublic WordChart AddChart<T, TCategory>(OfficeChartType type, IEnumerable<T?> data, Func<T?, TCategory?> category, OfficeChartOptions? options, params OfficeSeries[] series) #Adds an editable native chart from typed data with a title, size and optional format-specific placement.
Type Parameters
- T
- TCategory
Parameters
- type OfficeIMO.OfficeChartType
- data System.Collections.Generic.IEnumerable<T?>
- category System.Func<T?, TCategory?>
- options OfficeIMO.OfficeChartOptions?
- series OfficeIMO.OfficeSeries[]
Returns
WordChartpublic WordField AddCitation(string sourceTag) #Inserts a citation field referencing the specified source tag.
Parameters
- sourceTag string
- Tag of the bibliographic source.
public WordParagraph AddCodeBlock(string code, string? language = null) #Adds a code paragraph using a named monospace paragraph style. The language is a descriptive hint.
Parameters
- code string
- language string? = null
Returns
WordParagraphpublic WordChart AddComboChart(string title = "", bool roundedCorners = false, OfficeLength? width = null, OfficeLength? height = null) #Creates a chart ready for combining bar and line series. Use WordChart.AddCategories to supply category labels and then call WordChart.AddBar or WordChart.AddLine to add data. The call to AddCategories must be performed before adding any series so both chart types share the same axes.
Parameters
- title string = ""
- roundedCorners bool = false
- width OfficeIMO.OfficeLength? = null
- height OfficeIMO.OfficeLength? = null
Returns
WordChartpublic WordCoverPage AddCoverPage(WordCoverPageTemplate coverPageTemplate) #Adds a built-in cover page to the document.
Parameters
- coverPageTemplate OfficeIMO.Word.WordCoverPageTemplate
- Cover page template to use.
public WordList AddCustomBulletList(char symbol, string fontFamily, OfficeColor? color, OfficeLength? fontSize = null) #Adds a custom bullet list with formatting options.
Parameters
- symbol char
- Bullet symbol.
- fontFamily string
- Font family for the symbol.
- color OfficeIMO.OfficeColor?
- Color of the symbol.
- fontSize OfficeIMO.OfficeLength? = null
- Font size.
public WordList AddCustomBulletList(WordBulletSymbol symbol, string fontFamily, OfficeColor? color = null, OfficeLength? fontSize = null) #Adds a custom bullet list with formatting options.
Parameters
- symbol OfficeIMO.Word.WordBulletSymbol
- Bullet symbol.
- fontFamily string
- Font family for the symbol.
- color OfficeIMO.OfficeColor? = null
- Bullet color.
- fontSize OfficeIMO.OfficeLength? = null
- Font size in points.
public WordList AddCustomBulletList(WordListLevelKind kind, string fontFamily, OfficeColor? color = null, OfficeLength? fontSize = null) #Adds a custom bullet list using the specified formatting.
Parameters
- kind OfficeIMO.Word.WordListLevelKind
- Bullet level kind.
- fontFamily string
- Font family for the bullet.
- color OfficeIMO.OfficeColor? = null
- Bullet color.
- fontSize OfficeIMO.OfficeLength? = null
- Font size in points.
Examples
using WordDocument document = WordDocument.Create(filePath);
WordList list = document.AddCustomBulletList(
WordListLevelKind.BulletSquareSymbol,
"Courier New",
OfficeIMO.OfficeColor.Red,
fontSize: global::OfficeIMO.OfficeLength.Points(16));
list.AddItem("Custom bullet item");
document.Save();public WordList AddCustomList() #Creates a custom list with no predefined levels for manual configuration.
Examples
using WordDocument document = WordDocument.Create(filePath);
WordList list = document.AddCustomList();
list.AddListLevel(1, WordListLevelKind.BulletSquareSymbol, "Courier New", color: OfficeIMO.OfficeColor.Parse("#FF0000"), fontSize: global::OfficeIMO.OfficeLength.Points(14));
list.AddListLevel(5, WordListLevelKind.BulletBlackCircle, "Arial", color: OfficeIMO.OfficeColor.Parse("#00FF00"), fontSize: global::OfficeIMO.OfficeLength.Points(10));
list.AddItem("First level item");
list.AddItem("Fifth level item", 4);
document.Save();public WordEmbeddedDocument AddEmbeddedDocument(string fileName, WordAlternativeFormatImportPartType? type = null) #Embeds another document as an alternative format part.
Parameters
- fileName string
- Path to the document.
- type OfficeIMO.Word.WordAlternativeFormatImportPartType? = null
- Optional format part type.
public WordEmbeddedDocument AddEmbeddedFragment(string htmlContent, WordAlternativeFormatImportPartType type) #Embeds HTML content as an alternative format part.
Parameters
- htmlContent string
- HTML content to embed.
- type OfficeIMO.Word.WordAlternativeFormatImportPartType
- Format part type.
public WordEmbeddedDocument AddEmbeddedFragmentAfter(WordParagraph paragraph, string htmlContent, WordAlternativeFormatImportPartType type = Html) #Inserts an HTML fragment after the specified paragraph.
Parameters
- paragraph OfficeIMO.Word.WordParagraph
- Paragraph after which the fragment should be inserted.
- htmlContent string
- HTML content to insert.
- type OfficeIMO.Word.WordAlternativeFormatImportPartType = Html
- Optional format type of the fragment.
public WordEmbeddedObject AddEmbeddedObject(string filePath, string imageFilePath, OfficeLength? width = null, OfficeLength? height = null) #Embeds an object with a preview image.
Parameters
- filePath string
- Path to the object file.
- imageFilePath string
- Preview image path.
- width OfficeIMO.OfficeLength? = null
- Optional physical width; defaults to 64.8 points.
- height OfficeIMO.OfficeLength? = null
- Optional physical height; defaults to 64.8 points.
public WordEmbeddedObject AddEmbeddedObject(string filePath, WordEmbeddedObjectOptions options) #Embeds an object with custom options.
Parameters
- filePath string
- Path to the object file.
- options OfficeIMO.Word.WordEmbeddedObjectOptions
- Embedding options.
public WordEndnoteSettings AddEndnoteProperties(WordNumberFormat? numberingFormat = null, WordEndnotePosition? position = null, WordNoteNumberRestart? restartNumbering = null, int? startNumber = null) #Adds or updates endnote numbering for the first section and placement for the whole document.
Parameters
- numberingFormat OfficeIMO.Word.WordNumberFormat? = null
- Numbering format to apply.
- position OfficeIMO.Word.WordEndnotePosition? = null
- Document-wide endnote location. A position-only update preserves section numbering.
- restartNumbering OfficeIMO.Word.WordNoteNumberRestart? = null
- Restart numbering option.
- startNumber int? = null
- Starting number.
Returns
WordEndnoteSettingspublic WordEquation AddEquation(OfficeMathExpression expression) #Adds an editable Word equation authored with the reusable OfficeIMO math model.
Parameters
- expression OfficeIMO.Drawing.OfficeMathExpression
Returns
WordEquationpublic WordEquation AddEquation(string omml) #Inserts an equation specified in OMML format.
Parameters
- omml string
- OMML markup for the equation.
public WordField AddField(WordFieldType wordFieldType, WordFieldFormat? wordFieldFormat = null, string? customFormat = null, bool advanced = false, List<string>? parameters = null) #Adds a field to the document in a new paragraph.
Parameters
- wordFieldType OfficeIMO.Word.WordFieldType
- Type of field to insert.
- wordFieldFormat OfficeIMO.Word.WordFieldFormat? = null
- Optional field format.
- customFormat string? = null
- Custom format string for date or time fields.
- advanced bool = false
- Whether to use advanced formatting.
- parameters System.Collections.Generic.List<string>? = null
- Additional switch parameters.
public WordField AddField(WordFieldCode fieldCode, WordFieldFormat? wordFieldFormat = null, string? customFormat = null, bool advanced = false) #Adds 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 OfficeIMO.Word.WordFieldFormat? = null
- Optional field format.
- customFormat string? = null
- Custom format string for date or time fields.
- advanced bool = false
- Whether to use advanced formatting.
public WordField AddField(WordFieldBuilder builder, bool advanced = false) #Adds a field built using WordFieldBuilder.
Parameters
- builder OfficeIMO.Word.WordFieldBuilder
- Field builder instance.
- advanced bool = false
- Whether to use advanced formatting.
public WordFootnoteSettings AddFootnoteProperties(WordNumberFormat? numberingFormat = null, WordFootnotePosition? position = null, WordNoteNumberRestart? restartNumbering = null, int? startNumber = null) #Adds or updates footnote configuration for the first section.
Parameters
- numberingFormat OfficeIMO.Word.WordNumberFormat? = null
- Numbering format to apply.
- position OfficeIMO.Word.WordFootnotePosition? = null
- Location of footnotes.
- restartNumbering OfficeIMO.Word.WordNoteNumberRestart? = null
- Restart numbering option.
- startNumber int? = null
- Starting number.
Returns
WordFootnoteSettingspublic WordParagraph AddHeading(string text, int level = 1) #Adds a heading paragraph using the document's built-in heading style.
Parameters
- text string
- Heading text.
- level int = 1
- Heading level from one through nine.
public WordParagraph AddHorizontalLine(WordBorderStyle? lineType = null, OfficeColor? color = null, uint size = 12, uint space = 1) #Inserts a horizontal line into the document.
Parameters
- lineType OfficeIMO.Word.WordBorderStyle? = null
- Border style of the line.
- color OfficeIMO.OfficeColor? = null
- Line color.
- size uint = 12
- Line width in eighths of a point.
- space uint = 1
- Space above and below the line.
public WordHyperLink AddHyperLink(string text, Uri uri, bool addStyle = false, string tooltip = "", bool history = true) #Adds a hyperlink pointing to an external URI.
Parameters
- text string
- Display text for the hyperlink.
- uri System.Uri
- Target URI.
- addStyle bool = false
- Whether to apply hyperlink style.
- tooltip string = ""
- Tooltip for the hyperlink.
- history bool = true
- Whether to track link history.
public WordHyperLink AddHyperLink(string text, string anchor, bool addStyle = false, string tooltip = "", bool history = true) #Adds an internal hyperlink pointing to a bookmark.
Parameters
- text string
- Display text for the hyperlink.
- anchor string
- Bookmark anchor.
- addStyle bool = false
- Whether to apply hyperlink style.
- tooltip string = ""
- Tooltip for the hyperlink.
- history bool = true
- Whether to track link history.
public WordImage AddImage(string path, OfficeLength? width = null, OfficeLength? height = null, WordImageOptions? options = null) #Adds an image in a new paragraph and returns its editable occurrence.
Parameters
- path string
- width OfficeIMO.OfficeLength? = null
- height OfficeIMO.OfficeLength? = null
- options OfficeIMO.Word.WordImageOptions? = null
Returns
WordImagepublic WordImage AddImage(Stream stream, OfficeLength? width = null, OfficeLength? height = null, WordImageOptions? options = null) #Adds an image stream in a new paragraph without disposing the caller's stream.
Parameters
- stream System.IO.Stream
- width OfficeIMO.OfficeLength? = null
- height OfficeIMO.OfficeLength? = null
- options OfficeIMO.Word.WordImageOptions? = null
Returns
WordImagepublic async Task<WordImage> AddImageAsync(Uri uri, OfficeLength? width = null, OfficeLength? height = null, WordImageOptions? options = null, OfficeRemoteImageLoadOptions? remoteImageOptions = null, CancellationToken cancellationToken = default) #Downloads a bounded remote image and embeds it in a new paragraph.
Parameters
- uri System.Uri
- width OfficeIMO.OfficeLength? = null
- height OfficeIMO.OfficeLength? = null
- options OfficeIMO.Word.WordImageOptions? = null
- remoteImageOptions OfficeIMO.Drawing.OfficeRemoteImageLoadOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<WordImage>public WordList AddList(WordListStyle style) #Creates a list using one of the built-in numbering styles. For manually configured lists prefer WordDocument.AddCustomList.
Parameters
- style OfficeIMO.Word.WordListStyle
Returns
WordListpublic WordList AddListBulleted() #Adds a bulleted list using the default bulleted style.
public WordList AddListNumbered() #Adds a numbered list using the default numbering style.
public WordMacroProject AddMacro(string filePath) #Adds a VBA project to the document.
Parameters
- filePath string
- Path to a vbaProject.bin file.
Returns
WordMacroProjectpublic WordMacroProject AddMacro(byte[] data) #Adds a VBA project to the document from bytes.
Parameters
- data byte[]
- VBA project data.
Returns
WordMacroProjectpublic WordMacroProject AddMacro(Stream stream, long? maxBytes = null) #Adds or replaces a VBA project from a readable stream.
Parameters
- stream System.IO.Stream
- Stream containing vbaProject.bin.
- maxBytes long? = null
- Optional maximum number of bytes accepted from the stream.
Returns
WordMacroProjectpublic WordParagraph AddPageBreak() #Inserts a page break into the document.
public WordPageNumberSettings AddPageNumbering(int? startNumber = null, WordNumberFormat? format = null) #Adds or updates page numbering for the first section.
Parameters
- startNumber int? = null
- Starting page number.
- format OfficeIMO.Word.WordNumberFormat? = null
- Number format.
Returns
WordPageNumberSettingspublic WordParagraph AddParagraph(WordParagraph? wordParagraph = null) #Appends a paragraph to the document body.
Parameters
- wordParagraph OfficeIMO.Word.WordParagraph? = null
- Optional paragraph to append. When null a new paragraph is created.
public WordParagraph AddParagraph(string text) #Adds a new paragraph containing the specified text.
Parameters
- text string
- Text for the paragraph.
public WordList AddPictureBulletList(Stream imageStream, string fileName) #Creates a bullet list where the bullet symbol is provided as an image.
Parameters
- imageStream System.IO.Stream
- Stream containing the image data.
- fileName string
- File name used to determine the image type.
public WordList AddPictureBulletList(string imagePath) #Creates a bullet list where the bullet symbol is loaded from an image file.
Parameters
- imagePath string
- Path to the image file.
public WordRepeatingSection AddRepeatingSection(string? sectionTitle = null, string? alias = null, string? tag = null) #Adds a new paragraph with a repeating section content control.
Parameters
- sectionTitle string? = null
- Optional title of the repeating section.
- alias string? = null
- Optional alias for the control.
- tag string? = null
- Optional tag for the control.
public WordShape AddShape(WordShapeType shapeType, OfficeLength width, OfficeLength height, OfficeColor? fillColor = null, OfficeColor? strokeColor = null, OfficeLength? strokeWeight = null, double arcSize = 0.25) #Adds a basic shape to the document in a new paragraph.
Parameters
- shapeType OfficeIMO.Word.WordShapeType
- Type of shape to create.
- width OfficeIMO.OfficeLength
- Width or line end X.
- height OfficeIMO.OfficeLength
- Height or line end Y.
- fillColor OfficeIMO.OfficeColor? = null
- Fill color; white when omitted.
- strokeColor OfficeIMO.OfficeColor? = null
- Stroke color; black when omitted.
- strokeWeight OfficeIMO.OfficeLength? = null
- Stroke thickness; one point when omitted.
- arcSize double = 0.25
- Corner roundness fraction for rounded rectangles.
public WordShape AddShapeDrawing(WordShapeType shapeType, OfficeLength width, OfficeLength height) #Adds a DrawingML shape to the document in a new paragraph.
Parameters
- shapeType OfficeIMO.Word.WordShapeType
- Type of shape to create.
- width OfficeIMO.OfficeLength
- Width.
- height OfficeIMO.OfficeLength
- Height.
Returns
WordShapepublic WordShape AddShapeDrawing(WordShapeType shapeType, OfficeLength width, OfficeLength height, OfficeLength left, OfficeLength top) #Adds a DrawingML shape anchored at an absolute position on the page in a new paragraph.
Parameters
- shapeType OfficeIMO.Word.WordShapeType
- width OfficeIMO.OfficeLength
- height OfficeIMO.OfficeLength
- left OfficeIMO.OfficeLength
- top OfficeIMO.OfficeLength
Returns
WordShapepublic WordSmartArt AddSmartArt(WordSmartArtType type) #Inserts a SmartArt diagram into the document.
Parameters
- type OfficeIMO.Word.WordSmartArtType
- Layout type of the SmartArt.
public WordStructuredDocumentTag AddStructuredDocumentTag(string text, string? alias = null, string? tag = null) #Adds a new paragraph with a content control (structured document tag).
Parameters
- text string
- Initial text of the control.
- alias string? = null
- Optional alias for the control.
- tag string? = null
- Optional tag for the control.
public WordTable AddTable(IEnumerable<object?> items, OfficeTableOptions? options = null) #Adds a table from runtime objects by projecting their public properties or dictionary keys into columns.
Parameters
- items System.Collections.Generic.IEnumerable<object?>
- Objects to insert into the table. Column names come from the first item.
- options OfficeIMO.OfficeTableOptions? = null
- Common column selection, ordering, header, formatting, alignment, name and caption options. Pass WordTableOptions to choose the table style and layout mode.
public WordTable AddTable(int rows, int columns, WordTableStyle tableStyle = TableGrid) #Adds a table to the end of the document body.
Parameters
- rows int
- Number of rows to create.
- columns int
- Number of columns to create.
- tableStyle OfficeIMO.Word.WordTableStyle = TableGrid
- Optional table style to apply.
public WordTable AddTable(object?[,] values, OfficeTableOptions? options = null) #Adds an editable table from an existing rectangular matrix.
Parameters
- values object?[,]
- options OfficeIMO.OfficeTableOptions? = null
Returns
WordTablepublic WordTable AddTable(IEnumerable<string[]> rows, OfficeTableOptions? options = null) #Adds existing array rows as table cells. The first row is the header when headers are enabled.
Parameters
- rows System.Collections.Generic.IEnumerable<string[]>
- options OfficeIMO.OfficeTableOptions? = null
Returns
WordTablepublic WordTable AddTable(IEnumerable<IReadOnlyList<string>> rows, OfficeTableOptions? options = null) #Adds existing rows of text. The first row is the header when headers are enabled.
Parameters
- rows System.Collections.Generic.IEnumerable<System.Collections.Generic.IReadOnlyList<string>>
- options OfficeIMO.OfficeTableOptions? = null
Returns
WordTablepublic WordTableOfContent AddTableOfContent(WordTableOfContentsStyle tableOfContentStyle = Template1, int minLevel = 1, int maxLevel = 3, string? title = null, bool insertAtTop = false) #Adds a table of contents to the current document.
Parameters
- tableOfContentStyle OfficeIMO.Word.WordTableOfContentsStyle = Template1
- Optional style to use when creating the table of contents.
- minLevel int = 1
- Minimum heading level to include (1..9).
- maxLevel int = 3
- Maximum heading level to include (1..9).
- title string? = null
- Optional title replacing the template title.
- insertAtTop bool = false
- Places the table of contents before existing body content.
public WordList AddTableOfContentList(WordListStyle style) #Creates a list configured for a table of contents.
Parameters
- style OfficeIMO.Word.WordListStyle
- Numbering style to apply.
public WordTable AddTable<T>(IEnumerable<T?> rows, OfficeTableOptions? options = null) #Adds an editable table from a single pass over typed properties, fields, or string-keyed dictionaries.
Type Parameters
- T
Parameters
- rows System.Collections.Generic.IEnumerable<T?>
- options OfficeIMO.OfficeTableOptions? = null
Returns
WordTablepublic WordTextBox AddTextBox(string text, WordImageTextWrapping wrapTextImage = Square) #Inserts a text box into the document.
Parameters
- text string
- Initial text for the text box.
- wrapTextImage OfficeIMO.Word.WordImageTextWrapping = Square
- Text wrapping option.
public WordTextBox AddTextBoxVml(string text) #Inserts a VML text box into the document.
Parameters
- text string
Returns
WordTextBoxpublic WordImageOptimizationReport AnalyzeImageOptimization(WordImageOptimizationOptions? options = null, CancellationToken cancellationToken = default) #Evaluates exact encoded-media candidates without changing the document or fetching linked images. Candidate byte savings do not include ZIP packaging and document-save normalization.
Parameters
- options OfficeIMO.Word.WordImageOptimizationOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
WordImageOptimizationReportpublic void AppendDocument(WordDocument source) #Appends the content of another WordDocument to this document, keeping destination styles and the source page setup.
Parameters
- source OfficeIMO.Word.WordDocument
- The document to append.
public void AppendDocument(WordDocument source, WordDocumentMergeOptions? options) #Appends the content of another WordDocument to this document.
Parameters
- source OfficeIMO.Word.WordDocument
- The document to append.
- options OfficeIMO.Word.WordDocumentMergeOptions?
- Controls style and section handling. When null, defaults are used.
public WordDocument ApplyTheme(OfficeTheme theme) #Restyles the current document with the shared theme while retaining content, semantic emphasis, fields, relationships, table sizing and section geometry. Typography and cell padding can change pagination.
Parameters
- theme OfficeIMO.OfficeTheme
- The visual theme to apply explicitly.
public LegacyDocWriteAssessment AssessLegacyDocWrite(WordSaveOptions? options = null) #Runs the real native DOC encoder without committing an artifact and returns a structured capability result. This allocates the candidate DOC bytes so the assessment cannot drift from the writer used by WordDocument.Save.
Parameters
- options OfficeIMO.Word.WordSaveOptions? = null
Returns
LegacyDocWriteAssessmentpublic int CleanupDocument(WordDocumentCleanupOptions options = All) #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.WordDocumentCleanupOptions = All
Returns
intpublic WordSection CloneSection(int index) #Clones the section at the specified index and inserts the clone after it.
Parameters
- index int
- Zero based index of the section to clone.
public void ConvertRevisionsToMarkup() #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.
public static WordDocument Create(WordCreateOptions? options = null) #Create a new WordDocument
Parameters
- options OfficeIMO.Word.WordCreateOptions? = null
- Creation options. SaveOnDispose is invalid without an associated destination.
Returns
WordDocumentpublic static WordDocument Create(string filePath, WordCreateOptions? options = null) #Creates a Word document associated with a path that is written on explicit save.
Parameters
- filePath string
- Destination associated with the document.
- options OfficeIMO.Word.WordCreateOptions? = null
- Creation and persistence options.
Returns
WordDocumentpublic static WordDocument Create(Stream stream, WordCreateOptions? options = null) #Create a new WordDocument writing directly to the provided stream.
Parameters
- stream System.IO.Stream
- Destination stream.
- options OfficeIMO.Word.WordCreateOptions? = null
- Creation and persistence options.
Exceptions
ArgumentNullException– Thrown when stream is null.
public WordListNumbering CreateNumberingDefinition() #Creates a numbering definition that can be customized and reused.
public WordTable CreateTable(int rows, int columns, WordTableStyle tableStyle = TableGrid) #Creates a table without inserting it into the document.
Parameters
- rows int
- Number of rows to create.
- columns int
- Number of columns to create.
- tableStyle OfficeIMO.Word.WordTableStyle = TableGrid
- Optional table style to apply.
public void Dispose() #Releases resources associated with this WordDocument instance.
public async ValueTask DisposeAsync() #Releases resources associated with the document asynchronously.
Returns
ValueTaskpublic void EmbedFont(string fontPath) #Embeds a font into the document.
Parameters
- fontPath string
- Path to a TrueType/OpenType font file.
Exceptions
ArgumentException– The font's embedding permission forbids embedding it.
public WordStyle EmbedFont(string fontPath, string styleId, string? styleName = null) #Embeds a font and adds a paragraph style to this document that uses it.
Parameters
- fontPath string
- Path to a TrueType/OpenType font file.
- styleId string
- Identifier of the paragraph style. An existing style with this identifier is updated to use the font.
- styleName string? = null
- Optional friendly name for a new style.
Exceptions
ArgumentException– The font's embedding permission forbids embedding it, or the style cannot be used.
public byte[] ExportFlatOpc(WordSaveOptions? options = null) #Exports a Word Open XML package as a standalone Flat OPC XML document.
Parameters
- options OfficeIMO.Word.WordSaveOptions? = null
Returns
byte[]public Dictionary<string, object?> ExtractContentControlValues(WordContentControlFormKey keyMode = TagThenAlias) #Extracts values from supported content controls into a form map keyed by tag or alias.
Parameters
- keyMode OfficeIMO.Word.WordContentControlFormKey = TagThenAlias
- Controls which metadata field is used as the map key.
Returns
Dictionary<string, object?> Extracted form values.public byte[] ExtractEmbeddedPayload(string id, long? maxBytes = null) #Extracts an embedded payload by its package-local id.
Parameters
- id string
- Id returned by WordDocument.GetEmbeddedPayloads.
- maxBytes long? = null
- Optional extraction limit.
Returns
byte[]public int FillContentControlValues(IReadOnlyDictionary<string, object?> values, WordContentControlFormKey keyMode = TagThenAlias) #Fills supported content controls from a form map keyed by tag or alias.
Parameters
- values System.Collections.Generic.IReadOnlyDictionary<string, object?>
- Values to apply.
- keyMode OfficeIMO.Word.WordContentControlFormKey = TagThenAlias
- Controls which metadata field is used as the map key.
Returns
int The number of controls updated.Exceptions
InvalidOperationException– A supplied value targets locked content or would remove a locked nested control.
public WordSearchResult Find(string text, OfficeTextSearchOptions? options = null) #Finds literal text in the body, body tables, all section headers and footers, and ordinary footnotes and endnotes.
Parameters
- text string
- Text to find.
- options OfficeIMO.OfficeTextSearchOptions? = null
- Comparison settings. null matches ordinally, ignoring case, inside or across words.
Returns
WordSearchResult The paragraphs containing matches, grouped by document part, and the total match count.public WordSearchResult Find(Regex pattern) #Finds text matching a regular expression in the body, body tables, all section headers and footers, and ordinary footnotes and endnotes.
Parameters
- pattern System.Text.RegularExpressions.Regex
- Regular expression applied to each paragraph's text. Its own options control case and boundaries.
Returns
WordSearchResult The paragraphs containing matches, grouped by document part, and the total match count.public OfficeAccessibilityReport FixAccessibility(WordAccessibilityFixOptions options) #Applies the selected safe fixes (title, language, table header rows) and returns a fresh inspection with default options.
Parameters
- options OfficeIMO.Word.WordAccessibilityFixOptions
Returns
OfficeAccessibilityReportpublic WordCheckBox? GetCheckBoxByAlias(string alias) #Retrieves a checkbox control by its alias.
Parameters
- alias string
- Alias of the checkbox.
public WordCheckBox? GetCheckBoxByTag(string tag) #Retrieves a checkbox control by its tag value.
Parameters
- tag string
- Tag value of the checkbox.
public WordComboBox? GetComboBoxByAlias(string alias) #Retrieves a combo box control by its alias.
Parameters
- alias string
Returns
WordComboBox?public WordComboBox? GetComboBoxByTag(string tag) #Retrieves a combo box control by its tag value.
Parameters
- tag string
Returns
WordComboBox?public WordDatePicker? GetDatePickerByAlias(string alias) #Retrieves a date picker control by its alias.
Parameters
- alias string
- Alias of the date picker.
public WordDatePicker? GetDatePickerByTag(string tag) #Retrieves a date picker control by its tag value.
Parameters
- tag string
- Tag value of the date picker.
public string? GetDocumentVariable(string name) #Gets the value of a document variable or null if the variable does not exist.
Parameters
- name string
- Variable name.
Returns
string?public IReadOnlyDictionary<string, string> GetDocumentVariables() #Returns a read-only view of all document variables.
Returns
IReadOnlyDictionary<string, string>public WordDropDownList? GetDropDownListByAlias(string alias) #Retrieves a dropdown list control by its alias.
Parameters
- alias string
- Alias of the dropdown list.
public WordDropDownList? GetDropDownListByTag(string tag) #Retrieves a dropdown list control by its tag value.
Parameters
- tag string
- Tag value of the dropdown list.
public IReadOnlyList<OfficeEmbeddedPayloadInfo> GetEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions options, CancellationToken cancellationToken = default) #Inventories payloads within explicit count/member/aggregate/work ceilings without scanning unrequested bytes unless hashing is requested.
Parameters
- options OfficeIMO.OfficeEmbeddedPayloadInspectionOptions
- cancellationToken System.Threading.CancellationToken = default
Returns
IReadOnlyList<OfficeEmbeddedPayloadInfo>public IReadOnlyList<OfficeEmbeddedPayloadInfo> GetEmbeddedPayloads(bool includeSha256 = false) #Gets embedded package, OLE, and ActiveX payload metadata.
Parameters
- includeSha256 bool = false
- Whether to calculate a digest for every payload.
Returns
IReadOnlyList<OfficeEmbeddedPayloadInfo>public WordHeader? GetHeaderForSection(int sectionIndex = -1) #Returns the default header for a specific section index.
Parameters
- sectionIndex int = -1
- Index of the section or -1 for the last section.
Returns
WordHeader?public IReadOnlyList<byte[]> GetImageBytes() #Returns the bytes of all embedded images in the document. Images linked externally are skipped.
Returns
IReadOnlyList<byte[]>public WordListNumbering? GetNumberingDefinition(int abstractNumberId) #Retrieves a numbering definition by its identifier.
Parameters
- abstractNumberId int
- Identifier of the numbering definition.
public WordPictureControl? GetPictureControlByAlias(string alias) #Retrieves a picture control by its alias.
Parameters
- alias string
Returns
WordPictureControl?public WordPictureControl? GetPictureControlByTag(string tag) #Retrieves a picture control by its tag value.
Parameters
- tag string
Returns
WordPictureControl?public WordRepeatingSection? GetRepeatingSectionByAlias(string alias) #Retrieves a repeating section control by its alias.
Parameters
- alias string
Returns
WordRepeatingSection?public WordRepeatingSection? GetRepeatingSectionByTag(string tag) #Retrieves a repeating section control by its tag value.
Parameters
- tag string
Returns
WordRepeatingSection?public WordStructuredDocumentTag? GetStructuredDocumentTagByAlias(string alias) #Retrieves a structured document tag by its alias.
Parameters
- alias string
- Alias of the control.
public WordStructuredDocumentTag? GetStructuredDocumentTagByTag(string tag) #Retrieves a structured document tag by its tag value.
Parameters
- tag string
- Tag value of the control.
public WordParagraph InsertParagraphAt(int index, WordParagraph? paragraph = null) #Inserts a paragraph at the specified index within the body.
Parameters
- index int
- 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.
public WordTable InsertTableAfter(WordParagraph anchor, WordTable table) #Inserts 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.
public WordDocumentInfo Inspect() #Creates an independent snapshot of document metadata, sections, stories, paragraphs, tables, notes, and images.
Returns
WordDocumentInfo A snapshot suitable for inspection or serialization without retaining live Open XML elements.Exceptions
InvalidDataException– Generated list markers exceed the supported marker length or document character budget.
public WordDocumentInfo Inspect(bool includeImageBytes, CancellationToken cancellationToken = default) #Creates the native semantic snapshot, optionally retaining image descriptors without copying their payload bytes.
Parameters
- includeImageBytes bool
- When false, image payloads are not read or copied; image metadata remains available.
- cancellationToken System.Threading.CancellationToken = default
- Cancellation checked between source sections, paragraphs, table cells and notes.
Returns
WordDocumentInfopublic OfficeAccessibilityReport InspectAccessibility(WordAccessibilityOptions? options = null) #Inspects the document body against an accessibility policy: alternative text, headings, tables, links, contrast, floating objects, spacing, title and language.
Parameters
- options OfficeIMO.Word.WordAccessibilityOptions? = null
Returns
OfficeAccessibilityReportpublic OfficeEmbeddedPayloadInspection InspectEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions? options = null, CancellationToken cancellationToken = default) #Inventories inert native payloads and creates a bounded cumulative read session. Keep this document open for new reads; returned streams are detached and caller-owned.
Parameters
- options OfficeIMO.OfficeEmbeddedPayloadInspectionOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
OfficeEmbeddedPayloadInspectionpublic WordFeatureReport InspectFeatures() #Inspects document features and reports which ones OfficeIMO can edit, partially edit, preserve, or does not support yet.
Returns
WordFeatureReportpublic IReadOnlyList<WordFieldInfo> InspectFields() #Inspects simple and complex Word fields across the main document, headers, footers, footnotes and endnotes.
Returns
IReadOnlyList<WordFieldInfo> A deterministic read-only field inventory with raw instructions, parsed tokens, result text and location metadata.public OfficeContentSafetyReport InspectLoadedContentSafety(OfficeContentSafetyOptions? options = null, CancellationToken cancellationToken = default) #Inspects the currently loaded document without reopening, saving, or executing its content. Source-load limits remain the caller's responsibility.
Parameters
- options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
OfficeContentSafetyReportpublic WordReviewInfo InspectReview() #Inspects comments, comment thread metadata, and tracked revisions without mutating the document.
Returns
WordReviewInfopublic WordReviewInfo InspectReview(CancellationToken cancellationToken) #Inspects native review markup with cancellation between source elements, without accepting or rejecting revisions.
Parameters
- cancellationToken System.Threading.CancellationToken
Returns
WordReviewInfopublic WordReviewReport InspectReviewReport(params WordRevisionOperationReport[] actions) #Creates a structured review report for comments, tracked revisions, unsupported review metadata, and optional accept/reject actions.
Parameters
- actions OfficeIMO.Word.WordRevisionOperationReport[]
- Optional accept/reject operation reports to include in the report.
Returns
WordReviewReportpublic WordSignatureInfo InspectSignatures() #Inspects package-level digital-signature metadata without copying the encoded package or validating digests and cryptographic trust. Use WordDocument.ValidateSignatures for transform-aware digest and trust validation.
Returns
WordSignatureInfopublic OfficeVbaProjectInfo? InspectVbaProject(bool includeSha256 = false) #Inspects the attached VBA project without executing macro code.
Parameters
- includeSha256 bool = false
- Whether to calculate the project SHA-256 digest.
Returns
OfficeVbaProjectInfo? Project metadata, or null when the document has no VBA project.public OfficeVbaProjectInfo? InspectVbaProject(bool includeSha256, long maxBytes) #Inspects the attached VBA project while enforcing a decoded byte limit.
Parameters
- includeSha256 bool
- Whether to calculate the project SHA-256 digest.
- maxBytes long
- Maximum decoded VBA project bytes accepted.
Returns
OfficeVbaProjectInfo? Project metadata, or null when the document has no VBA project.public OfficeVbaProjectInfo? InspectVbaProjectMetadata() #Inventories the VBA part and signature relationship without reading its bytes or decoding module names. Payload length remains unknown.
Returns
OfficeVbaProjectInfo?public static WordDocument Load(string filePath, WordLoadOptions? options = null) #Load WordDocument from filePath
Parameters
- filePath string
- options OfficeIMO.Word.WordLoadOptions? = null
- Access, persistence, style, and low-level package options.
Returns
WordDocumentExceptions
FileNotFoundException
public static WordDocument Load(Stream stream, WordLoadOptions? options = null) #Load WordDocument from stream
Parameters
- stream System.IO.Stream
- Readable source. Editable writable seekable package sources become the associated destination; Word XML sources remain detached.
- options OfficeIMO.Word.WordLoadOptions? = null
- Access, persistence, style, and low-level package options.
Returns
WordDocumentpublic static WordDocument Load(string filePath, WordLoadOptions? options, out OfficeConversionReport report) #Loads a Word file and returns its source-projection findings.
Parameters
- filePath string
- options OfficeIMO.Word.WordLoadOptions?
- report OfficeIMO.OfficeConversionReport
Returns
WordDocumentpublic static WordDocument Load(Stream stream, WordLoadOptions? options, out OfficeConversionReport report) #Loads a Word stream and returns its source-projection findings.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordLoadOptions?
- report OfficeIMO.OfficeConversionReport
Returns
WordDocumentpublic static async Task<WordDocument> LoadAsync(string filePath, WordLoadOptions? options = null, CancellationToken cancellationToken = default) #Asynchronously loads a WordDocument from the given file.
Parameters
- filePath string
- Path to the file.
- options OfficeIMO.Word.WordLoadOptions? = null
- Access, persistence, style, and low-level package options.
- cancellationToken System.Threading.CancellationToken = default
- Cancellation token.
Exceptions
FileNotFoundException– Thrown when the file does not exist.
public static async Task<WordDocument> LoadAsync(Stream stream, WordLoadOptions? options = null, CancellationToken cancellationToken = default) #Asynchronously loads a Word document from a readable stream.
Parameters
- stream System.IO.Stream
- Stream containing binary DOC, Word Open XML, or standalone Word XML content.
- options OfficeIMO.Word.WordLoadOptions? = null
- Access, persistence, style, and low-level package options.
- cancellationToken System.Threading.CancellationToken = default
- Cancellation token.
public WordIndexConcordanceReport MarkIndexEntries(IEnumerable<WordIndexConcordanceEntry> entries, bool matchCase = false, bool matchWholeWord = true) #Marks matching paragraphs with hidden XE fields from in-memory concordance entries.
Parameters
- entries System.Collections.Generic.IEnumerable<OfficeIMO.Word.WordIndexConcordanceEntry>
- Concordance entries mapping search text to index text.
- matchCase bool = false
- Whether matching should be case-sensitive.
- matchWholeWord bool = true
- Whether matches require non-letter/digit boundaries around the search text.
public WordIndexConcordanceReport MarkIndexEntriesFromConcordance(WordDocument concordanceDocument, bool matchCase = false, bool matchWholeWord = true) #Reads a Word-style two-column concordance document and marks matching paragraphs with hidden XE fields.
Parameters
- concordanceDocument OfficeIMO.Word.WordDocument
- Concordance document whose first table column contains search text and second column contains index text.
- matchCase bool = false
- Whether matching should be case-sensitive.
- matchWholeWord bool = true
- Whether matches require non-letter/digit boundaries around the search text.
public WordIndexConcordanceReport MarkIndexEntriesFromConcordance(string concordancePath, bool matchCase = false, bool matchWholeWord = true) #Loads a Word-style two-column concordance document and marks matching paragraphs with hidden XE fields.
Parameters
- concordancePath string
- Path to a concordance .docx file.
- matchCase bool = false
- Whether matching should be case-sensitive.
- matchWholeWord bool = true
- Whether matches require non-letter/digit boundaries around the search text.
public void NormalizeTablesForOnline() #Walks all tables in body and headers/footers and normalizes their grid/widths so online viewers render them consistently.
public Stream OpenEmbeddedPayload(string id, long maximumBytes, CancellationToken cancellationToken = default) #Opens a complete bounded read-only detached payload stream. The caller owns its lifetime; no external target is accessed.
Parameters
- id string
- maximumBytes long
- cancellationToken System.Threading.CancellationToken = default
Returns
Streampublic IReadOnlyList<Stream> OpenImageStreams() #Returns streams with data of all embedded images in the document. Images linked externally are skipped.
Returns
IReadOnlyList<Stream>public void OpenInApplication(string? filePath = null) #Opens the associated document in the operating system's registered application.
Parameters
- filePath string? = null
public WordImageOptimizationReport OptimizeImages(WordImageOptimizationOptions? options = null, CancellationToken cancellationToken = default) #Optimizes unique embedded raster media while retaining every relationship and drawing's geometry. All candidates are staged before mutation. Cancellation or candidate failure leaves media unchanged. Save through the normal Word save API to persist changes; signed packages are blocked by default.
Parameters
- options OfficeIMO.Word.WordImageOptimizationOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
WordImageOptimizationReportpublic OfficeVbaProject? ReadVbaProject(OfficeVbaReadOptions? options = null) #Reads a detached, editable native VBA project; returns null when no project exists.
Parameters
- options OfficeIMO.OfficeVbaReadOptions? = null
Returns
OfficeVbaProject?public WordTableOfContent RegenerateTableOfContent() #Removes the existing table of contents and creates a new one at the same location.
public void RejectRevisions(string authorName) #Reject all revisions by given author.
Parameters
- authorName string
- Author whose revisions should be rejected.
public WordRevisionOperationReport RejectRevisions(WordRevisionFilter filter) #Rejects revisions that match the provided filter and returns a deterministic operation report.
Parameters
- filter OfficeIMO.Word.WordRevisionFilter
- Filter describing revisions to reject.
Returns
WordRevisionOperationReportpublic WordRevisionOperationReport RejectRevisionsInParagraph(WordParagraph paragraph, WordRevisionFilter? filter = null) #Rejects revisions inside the specified paragraph.
Parameters
- paragraph OfficeIMO.Word.WordParagraph
- Paragraph that scopes the operation.
- filter OfficeIMO.Word.WordRevisionFilter? = null
- Optional additional filter.
Returns
WordRevisionOperationReportpublic void RemoveAllComments() #Removes all comments from the document.
public void RemoveComment(string commentId) #Removes comment with the specified id.
Parameters
- commentId string
- Id of the comment to remove.
public void RemoveComment(WordComment comment) #Removes the specified comment from the document.
Parameters
- comment OfficeIMO.Word.WordComment
- Comment instance to remove.
public void RemoveDocumentVariable(string name) #Removes the document variable with the specified name if present.
Parameters
- name string
- Variable name.
public void RemoveDocumentVariableAt(int index) #Removes the document variable at the specified index.
Parameters
- index int
- Zero-based index of the variable to remove.
Exceptions
ArgumentOutOfRangeException– Thrown when index is out of range.
public void RemoveEmbeddedDocument(WordEmbeddedDocument embeddedDocument) #Removes an embedded document from the document.
Parameters
- embeddedDocument OfficeIMO.Word.WordEmbeddedDocument
- Embedded document to remove.
public bool RemoveEmbeddedPayload(string id) #Removes an embedded payload and known Word OLE/control markup that references it.
Parameters
- id string
Returns
boolpublic void RemoveMacro(string name) #Removes a standard or class VBA module from the document.
Parameters
- name string
- Module name to remove.
Exceptions
NotSupportedException– The named module belongs to the host document or a designer.
public static OfficeProvenanceRemovalResult RemoveProvenance(string inputPath, string outputPath, OfficeProvenanceRemovalOptions? options = null) #Removes selected provenance and atomically writes an Open XML document.
Parameters
- inputPath string
- outputPath string
- options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null
Returns
OfficeProvenanceRemovalResultpublic static OfficeProvenanceRemovalResult RemoveProvenance(byte[] documentBytes, string fileName = "document.docx", OfficeProvenanceRemovalOptions? options = null) #Removes selected provenance from encoded Open XML document bytes.
Parameters
- documentBytes byte[]
- fileName string = "document.docx"
- options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null
Returns
OfficeProvenanceRemovalResultpublic void RemoveSection(int index) #Removes the section at the specified index.
Parameters
- index int
- Zero based index of the section to remove.
public static OfficeContentCleanupResult RemoveSelectedContent(byte[] documentBytes, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null) #Removes exact selected concealed-content findings and reinspects the encoded document.
Parameters
- documentBytes byte[]
- selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection
- options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null
Returns
OfficeContentCleanupResultpublic static OfficeContentCleanupResult RemoveSelectedContent(string inputPath, string outputPath, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null) #Atomically writes an explicitly cleaned DOCX-family artifact.
Parameters
- inputPath string
- outputPath string
- selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection
- options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null
Returns
OfficeContentCleanupResultpublic void RemoveTableOfContent() #Removes the current table of contents from the document if one exists.
public void RemoveWatermark() #Removes all watermarks from the document including headers.
public int ReplaceAll(string text, string replacement, OfficeTextSearchOptions? options = null) #Replaces literal text in the body, body tables, all section headers and footers, and ordinary footnotes and endnotes.
Parameters
- text string
- Text to find.
- replacement string
- Replacement text; null removes each match.
- options OfficeIMO.OfficeTextSearchOptions? = null
- Comparison settings. null matches ordinally, ignoring case, inside or across words.
Returns
int The number of replaced matches.public static int ReplaceAll(List<WordParagraph> paragraphs, string text, string replacement, OfficeTextSearchOptions? options = null) #Replaces literal text within the supplied paragraphs, such as the paragraphs of one table cell.
Parameters
- paragraphs System.Collections.Generic.List<OfficeIMO.Word.WordParagraph>
- Paragraphs to search, in document order.
- text string
- Text to find.
- replacement string
- Replacement text; null removes each match.
- options OfficeIMO.OfficeTextSearchOptions? = null
- Comparison settings. null matches ordinally, ignoring case, inside or across words.
Returns
int The number of replaced matches.public int ReplaceAll(Regex pattern, string replacement) #Replaces regular-expression matches in the body, body tables, all section headers and footers, and ordinary footnotes and endnotes.
Parameters
- pattern System.Text.RegularExpressions.Regex
- Regular expression applied to each paragraph's text.
- replacement string
- Replacement pattern with the substitutions of Regex.Replace, such as $1 or ${name}.
Returns
int The number of replaced matches.public int ReplaceAll(Regex pattern, MatchEvaluator evaluator) #Replaces regular-expression matches with text computed for each match, in the same parts as WordDocument.ReplaceAll.
Parameters
- pattern System.Text.RegularExpressions.Regex
- Regular expression applied to each paragraph's text.
- evaluator System.Text.RegularExpressions.MatchEvaluator
- Returns the replacement text for a match.
Returns
int The number of replaced matches.public int ReplaceAll(Regex pattern, Action<Match, WordParagraph> content) #Replaces regular-expression matches with content added through a paragraph, such as formatted text, a hyperlink or an image, in the same parts as WordDocument.ReplaceAll.
Parameters
- pattern System.Text.RegularExpressions.Regex
- Regular expression applied to each paragraph's text.
- content System.Action<System.Text.RegularExpressions.Match, OfficeIMO.Word.WordParagraph>
- Adds the replacement for a match, for example (m, p) => p.AddText(m.Groups[1].Value).SetBold().
Returns
int The number of replaced matches.public void ReplaceEmbeddedPayload(string id, byte[] data) #Replaces an embedded payload while preserving its owner relationship.
Parameters
- id string
- data byte[]
public void ReplaceEmbeddedPayload(string id, Stream stream, long? maxBytes = null) #Replaces an embedded payload from a readable stream.
Parameters
- id string
- stream System.IO.Stream
- maxBytes long? = null
public int ReplaceTextWithHtmlFragment(string textToFind, string htmlContent, WordAlternativeFormatImportPartType type = Html, StringComparison stringComparison = OrdinalIgnoreCase) #Replaces each occurrence of text in consecutive body paragraphs with a block-level AltChunk at the match location, splitting a paragraph when necessary.
Parameters
- textToFind string
- Text to search for.
- htmlContent 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
int The number of replacements performed.Exceptions
NotSupportedException– A match intersects content that cannot be split or removed as body text, such as a field, content control, revision, or explicit page or column break. The operation also rejects a match that would move a paragraph's page-break-before boundary.
public void Save(WordSaveOptions? options) #Saves to the associated destination with optional save settings.
Parameters
- options OfficeIMO.Word.WordSaveOptions?
public void Save(string filePath, WordSaveOptions? options) #Save WordDocument to the given file path with optional save policy settings.
Parameters
- filePath string
- Destination path.
- options OfficeIMO.Word.WordSaveOptions?
- Optional save policy settings.
public void Save(Stream outputStream) #Save the WordDocument to Stream
Parameters
- outputStream System.IO.Stream
Exceptions
InvalidOperationException
public void Save(Stream outputStream, WordSaveOptions? options) #Save the WordDocument to Stream with optional save behavior.
Parameters
- outputStream System.IO.Stream
- Writable stream that receives the document content. This one-time save does not change the associated destination.
- options OfficeIMO.Word.WordSaveOptions?
- Optional save behaviors, including stream physical format selection and signed-document policy.
Exceptions
InvalidOperationException
public Task SaveAsync(CancellationToken cancellationToken = default) #Asynchronously saves the document to where it was open from.
Parameters
- cancellationToken System.Threading.CancellationToken = default
- Cancellation token.
Returns
Taskpublic Task SaveAsync(WordSaveOptions? options, CancellationToken cancellationToken = default) #Asynchronously saves to the associated destination with optional save settings.
Parameters
- options OfficeIMO.Word.WordSaveOptions?
- cancellationToken System.Threading.CancellationToken = default
Returns
Taskpublic Task SaveAsync(string filePath, CancellationToken cancellationToken = default) #Asynchronously saves the document to the specified file.
Parameters
- filePath string
- The path to save the document to.
- cancellationToken System.Threading.CancellationToken = default
- Cancellation token.
Returns
Taskpublic Task SaveAsync(string filePath, WordSaveOptions? options, CancellationToken cancellationToken = default) #Asynchronously saves the document to the specified file with optional save policy settings.
Parameters
- filePath string
- The path to save the document to.
- options OfficeIMO.Word.WordSaveOptions?
- Optional save policy settings.
- cancellationToken System.Threading.CancellationToken = default
- Cancellation token.
Returns
Taskpublic Task SaveAsync(Stream outputStream, CancellationToken cancellationToken = default) #Asynchronously saves the document to a stream as DOCX.
Parameters
- outputStream System.IO.Stream
- Writable destination stream.
- cancellationToken System.Threading.CancellationToken = default
- Cancellation token.
Returns
Taskpublic Task SaveAsync(Stream outputStream, WordSaveOptions? options, CancellationToken cancellationToken = default) #Asynchronously saves the document to a stream as DOCX.
Parameters
- outputStream System.IO.Stream
- Writable destination stream.
- options OfficeIMO.Word.WordSaveOptions?
- Optional save policy settings.
- cancellationToken System.Threading.CancellationToken = default
- Cancellation token.
Returns
Taskpublic void SaveCopy(string filePath, WordSaveOptions? options = null) #Saves an independent copy without changing this document's associated destination.
Parameters
- filePath string
- Destination path.
- options OfficeIMO.Word.WordSaveOptions? = null
- Optional save policy settings.
public async Task SaveCopyAsync(string filePath, WordSaveOptions? options = null, CancellationToken cancellationToken = default) #Asynchronously saves an independent copy without changing this document's associated destination.
Parameters
- filePath string
- options OfficeIMO.Word.WordSaveOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Taskpublic void SaveEmbeddedPayload(string id, string filePath, long? maxBytes = null) #Saves an embedded payload by its package-local id.
Parameters
- id string
- filePath string
- maxBytes long? = null
public void SetDocumentVariable(string name, string value) #Sets the value of a document variable. Creates it if it does not exist.
Parameters
- name string
- Variable name.
- value string
- Variable value.
public void SetVbaProject(OfficeVbaProject project, OfficeVbaWriteOptions? options = null) #Applies a native source project while preserving Word's VBA data and requiring explicit signature removal.
Parameters
- project OfficeIMO.OfficeVbaProject
- options OfficeIMO.OfficeVbaWriteOptions? = null
public static WordMacroProjectSigningResult SignMacroProject(string filePath, IOfficeSecurityProvider securityProvider, string certificateThumbprint, WordMacroProjectSigningOptions? options = null) #Clears existing VBA signatures, creates and verifies Microsoft's legacy, agile, and V3 profiles, and atomically commits the signed package or throws with a structured result.
Parameters
- filePath string
- Path to a saved DOCM or DOTM package.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificateThumbprint string
- SHA-1 thumbprint of a certificate with an accessible private key in the configured store.
- options OfficeIMO.Word.WordMacroProjectSigningOptions? = null
- Optional certificate-store, OfficeSips, timestamp, validation, and resource policy.
public static OfficePackageSigningResult SignPackage(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficePackageSigningOptions? options) #Creates and validates an OPC signature through the shared cross-host engine.
Parameters
- filePath string
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficePackageSigningOptions?
Returns
OfficePackageSigningResultpublic static WordPackageSigningResult SignPackage(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 certificate, WordPackageSigningOptions? options = null) #Signs a saved DOCX package using the cross-platform OPC XML-signature engine and throws when signing cannot be completed and cryptographically verified.
Parameters
- filePath string
- Path to the DOCX package to sign.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificate System.Security.Cryptography.X509Certificates.X509Certificate2
- Certificate with a private key used for signing.
- options OfficeIMO.Word.WordPackageSigningOptions? = null
- Optional package-signing settings.
Returns
WordPackageSigningResult A signing result with structural, cryptographic, digest, and certificate-policy validation readback.public static WordPackageSigningResult SignPackage(string filePath, IOfficeSecurityProvider securityProvider, string certificateThumbprint, WordPackageCertificateStoreOptions? certificateOptions = null, WordPackageSigningOptions? signingOptions = null) #Resolves a signing certificate by thumbprint from the certificate store, signs a saved DOCX package, and throws when signing cannot be completed and cryptographically verified.
Parameters
- filePath string
- Path to the DOCX package to sign.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificateThumbprint string
- Certificate thumbprint to locate.
- certificateOptions OfficeIMO.Word.WordPackageCertificateStoreOptions? = null
- Optional certificate-store lookup settings.
- signingOptions OfficeIMO.Word.WordPackageSigningOptions? = null
- Optional package-signing settings.
Returns
WordPackageSigningResult A signing result with structural, cryptographic, digest, and certificate-policy validation readback.public static OfficeVbaSigningResult SignVbaProject(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeVbaSigningOptions? options = null, IEnumerable<X509Certificate2>? certificateChain = null) #Creates and atomically validates legacy, agile, and V3 VBA signatures through the shared owner.
Parameters
- filePath string
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficeVbaSigningOptions? = null
- certificateChain System.Collections.Generic.IEnumerable<System.Security.Cryptography.X509Certificates.X509Certificate2>? = null
Returns
OfficeVbaSigningResultpublic IReadOnlyList<WordDocument> SplitByHeading(int level = 1) #Splits this document into one new document per heading, starting a piece at every top-level paragraph whose heading level is level or higher (for example every Heading 1 when the level is 1).
Parameters
- level int = 1
- The deepest heading level that starts a new piece, from 1 to 9.
Returns
IReadOnlyList<WordDocument> The pieces in document order. Each is detached and must be saved with an explicit destination.public IReadOnlyList<WordDocument> SplitBySection() #Splits this document into one new document per section.
Returns
IReadOnlyList<WordDocument> The pieces in document order. Each is detached and must be saved with an explicit destination.public bool StyleExists(string styleId) #Determines whether a paragraph style with the specified identifier exists in the document.
Parameters
- styleId string
- The case-sensitive style identifier to look for.
Returns
bool true if the style exists; otherwise, false.public byte[] ToBytes(WordSaveOptions? options = null) #Encodes this document using the selected physical format and output encryption.
Parameters
- options OfficeIMO.Word.WordSaveOptions? = null
Returns
byte[]public bool TryGetCompatibilitySourcePayload(out OfficeCompatibilitySourcePayload? payload, out string? error) #Tries to read an original source retained by a compatibility conversion.
Parameters
- payload OfficeIMO.OfficeCompatibilitySourcePayload?
- error string?
Returns
boolpublic static WordMacroProjectSigningResult TrySignMacroProject(string filePath, IOfficeSecurityProvider securityProvider, string certificateThumbprint, WordMacroProjectSigningOptions? options = null) #Attempts to clear existing VBA signatures, create Microsoft's legacy, agile, and V3 profiles, verify every profile as it is created, prove VBA-project preservation, and atomically replace the file.
Parameters
- filePath string
- Path to a saved DOCM or DOTM package.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificateThumbprint string
- SHA-1 thumbprint of a certificate with an accessible private key in the configured store.
- options OfficeIMO.Word.WordMacroProjectSigningOptions? = null
- Optional certificate-store, OfficeSips, timestamp, validation, and resource policy.
public static OfficePackageSigningResult TrySignPackage(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficePackageSigningOptions? options) #Attempts shared OPC signature creation without throwing for an ordinary signing failure.
Parameters
- filePath string
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficePackageSigningOptions?
Returns
OfficePackageSigningResultpublic static WordPackageSigningResult TrySignPackage(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 certificate, WordPackageSigningOptions? options = null) #Attempts to sign a saved DOCX package and returns a report instead of throwing for unsupported platforms or signing failures.
Parameters
- filePath string
- Path to the DOCX package to sign.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificate System.Security.Cryptography.X509Certificates.X509Certificate2
- Certificate with a private key used for signing.
- options OfficeIMO.Word.WordPackageSigningOptions? = null
- Optional package-signing settings.
Returns
WordPackageSigningResult A signing result with details and validation readback when available.public static WordPackageSigningResult TrySignPackage(string filePath, IOfficeSecurityProvider securityProvider, string certificateThumbprint, WordPackageCertificateStoreOptions? certificateOptions = null, WordPackageSigningOptions? signingOptions = null) #Attempts to resolve a signing certificate by thumbprint from the certificate store and sign a saved DOCX package.
Parameters
- filePath string
- Path to the DOCX package to sign.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificateThumbprint string
- Certificate thumbprint to locate.
- certificateOptions OfficeIMO.Word.WordPackageCertificateStoreOptions? = null
- Optional certificate-store lookup settings.
- signingOptions OfficeIMO.Word.WordPackageSigningOptions? = null
- Optional package-signing settings.
Returns
WordPackageSigningResult A signing result with details and validation readback when available.public static OfficeVbaSigningResult TrySignVbaProject(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeVbaSigningOptions? options = null, IEnumerable<X509Certificate2>? certificateChain = null) #Attempts shared atomic VBA signing and returns structured failure evidence.
Parameters
- filePath string
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficeVbaSigningOptions? = null
- certificateChain System.Collections.Generic.IEnumerable<System.Security.Cryptography.X509Certificates.X509Certificate2>? = null
Returns
OfficeVbaSigningResultpublic void UpdateFields() #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 void UpdateFields(WordFieldUpdateOptions options) #Updates page and total page number fields, using the supplied options for supported deterministic field refresh.
Parameters
- options OfficeIMO.Word.WordFieldUpdateOptions
- Options controlling deterministic field refresh behavior.
public WordFieldUpdateReport UpdateFieldsAndGetReport() #Updates deterministic field results supported by OfficeIMO and returns structured per-field diagnostics.
Returns
WordFieldUpdateReport A report describing updated, skipped, unsupported and malformed fields.public WordFieldUpdateReport UpdateFieldsAndGetReport(WordFieldUpdateOptions options) #Updates deterministic field results supported by OfficeIMO and returns structured per-field diagnostics.
Parameters
- options OfficeIMO.Word.WordFieldUpdateOptions
- Options controlling deterministic field refresh behavior.
Returns
WordFieldUpdateReport A report describing updated, skipped, unsupported and malformed fields.public WordContentControlFormValidationResult ValidateContentControlValues(IReadOnlyDictionary<string, object?> values, WordContentControlFormKey keyMode = TagThenAlias, bool requireAllControls = true, bool allowUnusedValues = false) #Validates a content-control form map before values are applied to the document.
Parameters
- values System.Collections.Generic.IReadOnlyDictionary<string, object?>
- Values to validate.
- keyMode OfficeIMO.Word.WordContentControlFormKey = TagThenAlias
- Controls which metadata field is used as the map key.
- requireAllControls bool = true
- When true, report mapped controls that have no supplied value.
- allowUnusedValues bool = false
- When false, report supplied values that do not match a mapped control.
Returns
WordContentControlFormValidationResult Validation result containing expected keys, supplied keys, and issues.public List<OfficeOpenXmlValidationError> ValidateDocument(OfficeOpenXmlFileFormatVersion fileFormatVersion = Microsoft365) #Validates the document using the specified file format version.
Parameters
- fileFormatVersion OfficeIMO.OfficeOpenXmlFileFormatVersion = Microsoft365
- File format version to validate against.
Returns
List<OfficeOpenXmlValidationError> List of validation errors.public static WordMacroProjectSignatureValidationResult ValidateMacroProjectSignature(string filePath, IOfficeSecurityProvider securityProvider, WordMacroProjectSignatureValidationOptions? options = null) #Validates the highest-precedence VBA signature against the macro project through Microsoft's registered Office SIP, then applies caller CMS, certificate-chain, revocation, and timestamp policy.
Parameters
- filePath string
- Path to a saved DOCM or DOTM package.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- options OfficeIMO.Word.WordMacroProjectSignatureValidationOptions? = null
- Optional native-tool and validation policy.
public static OfficePackageSignatureValidationReport ValidateSignatures(string filePath, IOfficeSecurityProvider securityProvider, OfficePackageSignatureValidationOptions? options = null) #Validates a saved DOCX/DOCM package through the shared optional-provider engine.
Parameters
- filePath string
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- options OfficeIMO.Security.OfficePackageSignatureValidationOptions? = null
Returns
OfficePackageSignatureValidationReportpublic WordSignatureValidationReport ValidateSignatures(IOfficeSecurityProvider securityProvider, WordSignatureValidationOptions? options = null) #Validates package structure, transform-aware OPC digests, XML signature math, signer trust, revocation, and timestamps through an explicitly supplied security provider.
Parameters
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the caller, typically OfficeSecurityProvider.Default.
- options OfficeIMO.Word.WordSignatureValidationOptions? = null
- Trust, revocation, timestamp, and resource policy.
public static OfficeVbaSignatureValidationResult ValidateVbaSignatures(string filePath, IOfficeSecurityProvider securityProvider, OfficeVbaSignatureInspectionOptions? options = null) #Validates VBA signatures through the package-neutral core shared with Excel and PowerPoint.
Parameters
- filePath string
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- options OfficeIMO.Security.OfficeVbaSignatureInspectionOptions? = null
Returns
OfficeVbaSignatureValidationResultInherited Methods
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<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<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 WordPageSetup PageSetup { get; } #Gets the page size, margins, orientation and running headers and footers of the first section.
public OfficePackageSecurityReport? SourcePackageSecurityReport { get; private set; } #Structural observations captured from the exact loader source bytes when requested; subsequent edits do not change this source report.
public string? SourcePackageSecurityScope { get; private set; } #Identifies whether captured observations describe the original source, its decrypted package, or a reconstructed package.
public WordFileFormat SourceFormat { get; private set; } #Gets the detected physical format of the document source.
public OfficeFormatDescriptor SourceFormatDescriptor { get; } #Gets the concrete source format, including modern template and macro variants.
public string? SourcePath { get; } #Gets the original binary or standalone XML source path, or the current Open XML file association.
public IReadOnlyList<LegacyDocImportDiagnostic> LegacyDocImportDiagnostics { get; } #Gets diagnostics produced while importing the legacy `.doc` document.
public IReadOnlyList<LegacyDocUnsupportedFeature> LegacyDocUnsupportedFeatures { get; } #Gets unsupported or preserve-only features discovered while importing the legacy `.doc` document.
public IReadOnlyList<LegacyDocPreservedFeature> LegacyDocPreservedFeatures { get; } #Gets preserve-only non-compound feature metadata discovered while importing the legacy `.doc` document.
public IReadOnlyList<LegacyDocCompoundFeature> LegacyDocCompoundFeatures { get; } #Gets preserve-only compound storage discovered while importing the legacy `.doc` document.
public bool IsDisposed { get; } #Whether this document has released its package and owned resources.
public bool HasMacros { get; } #Provides basic support for VBA macro projects.
public IReadOnlyList<WordMacro> Macros { get; } #Gets all VBA modules in the document, including host document and designer modules.
public List<WordComment> Comments { get; } #Collection of all comments inserted into the document.
public bool HasDocumentVariables { get; } #Determines whether the document contains any document variables.
public bool TrackChanges { get; set; } #Enable or disable tracking of all revisions, moves and formatting changes.
public List<WordSection> Sections { get; } #Collection of sections contained in the document.
public string? FilePath { get; internal set; } #Path to the file backing this document.
public WordSettings Settings { get; internal set; } #Provides access to document settings. A missing settings part is created on first use.
public WordApplicationProperties ApplicationProperties { get; internal set; } #Manages application related properties.
public WordBuiltinDocumentProperties Properties { get; internal set; } #Provides access to built-in document properties.
public WordCoverPageProperties CoverPageProperties { get; } #Provides access to the cover page properties custom XML part used by built-in templates.
public Dictionary<string, WordCustomProperty> CustomProperties { get; } #Collection of custom document properties.
public Dictionary<string, string> DocumentVariables { get; } #Collection of document variables accessible via WordFieldType.DocVariable fields.
public Dictionary<string, WordBibliographySource> BibliographySources { get; } #Collection of bibliographic sources used in the document.
public WordDocumentStatistics Statistics { get; internal set; } #Provides basic statistics for the document.
public DocumentPersistenceMode PersistenceMode { get; } #Gets the persistence policy selected when the document was created or loaded.
public bool AutoUpdateToc { get; set; } #When true the table of contents is flagged to update before saving.
public WordprocessingDocument OpenXmlDocument { get; } #Gets the underlying Open XML package for advanced integration scenarios.
public FileAccess FileOpenAccess { get; } #FileOpenAccess of the document
public DocumentAccessMode AccessMode { get; } #Gets whether the document was loaded for reading or editing.
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 IReadOnlyList<WordStructuredDocumentTag> TextContentControls { get; } #Gets generic text content controls without the SDT wrappers belonging to native check boxes, dates, choices, pictures or repeating sections.
public WordBorders Borders { get; set; } #Gets or sets the page borders for the first section.
public bool 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 WordStyleCollection Styles { get; } #Gets the styles this document defines, to list, inspect, create, change, remove and import them.
public WordTheme Theme { get; } #Gets the document theme: its colour scheme and its heading and body fonts.
public WordBackground Background { get; set; } #Provides access to the document background settings.
public bool DocumentIsValid { get; } #Indicates whether the document passes Open XML validation.
public List<OfficeOpenXmlValidationError> 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 WordPageNumberSettings PageNumberSettings { get; } #Gets the editable configuration of the first section's page-numbering configuration.
public WordFootnoteSettings FootnoteSettings { get; } #Gets the editable configuration of the first section's footnote configuration.
public WordEndnoteSettings EndnoteSettings { get; } #Gets the editable configuration of the first section's endnote configuration.
Extension Methods
public static WordParagraph AddParagraphFromXml(WordDocument document, string xml) #Creates a WordParagraph from the provided XML string and appends it to the document.
Parameters
- document OfficeIMO.Word.WordDocument
- Target document.
- xml string
- XML string representing a paragraph.