API Reference

Cmdlet

Find-OfficeWordTable

Namespace PSWriteOffice
Inputs
OfficeIMO.Word.WordDocument
Outputs
OfficeIMO.Word.WordTable

Finds Word tables containing matching cell text.

Remarks

Searches table cell paragraphs in a Word document and returns the matching WordTable objects. Use this when a document came from a template or another system and the script needs to locate a table by visible marker text before appending rows, changing cells, or applying table-cell formatting. By default only top-level tables are searched. Use -IncludeNested to include tables inside table cells. Use -Text for literal contains matching or -Pattern for regular expressions.

Examples

Authored help example

Find the table that contains a marker and append a row.

PS>


$doc = Get-OfficeWord -Path .\Report.docx
            $table = Find-OfficeWordTable -Document $doc -Text 'Risk register' | Select-Object -First 1
            $table | Add-OfficeWordTableRow -Values 'Contoso', 'Open', 'High'
        

Searches table cell paragraphs and returns the matching OfficeIMO table object.

Find a risk table, append a row, and update a status cell.

PS>


$doc = Get-OfficeWord -Path .\Handover.docx
            $table = Find-OfficeWordTable -Document $doc -Text 'Risk marker' | Select-Object -First 1
            $table | Add-OfficeWordTableRow -Values 'Mitigation plan', 'Service Desk', 'Ready'
            $table | Get-OfficeWordTableCell -Row 2 -Column 2 |
                Set-OfficeWordTableCell -Text 'Investigating' -ShadingFillColor '#fff2cc' -ShadingPattern Clear
            $doc | Close-OfficeWord -Save
        

Shows the common existing-document workflow: locate the table, mutate it, then save the open document.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.

Syntax

Find-OfficeWordTable [-CaseSensitive] [-IncludeNested] -InputPath <String> -Text <String> [<CommonParameters>]
#
Parameter set: PathText

Parameters

CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching.
IncludeNested SwitchParameter optionalposition: namedpipeline: False
Include nested tables inside table cells.
InputPath String requiredposition: 0pipeline: Falsealiases: FilePath, Path
Path to the document to open read-only for searching.
Text String requiredposition: 1pipeline: False
Literal text to find in table cells.

Outputs

OfficeIMO.Word.WordTable

Find-OfficeWordTable [-CaseSensitive] [-IncludeNested] -InputPath <String> -Pattern <String> [<CommonParameters>]
#
Parameter set: PathRegex

Parameters

CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching.
IncludeNested SwitchParameter optionalposition: namedpipeline: False
Include nested tables inside table cells.
InputPath String requiredposition: 0pipeline: Falsealiases: FilePath, Path
Path to the document to open read-only for searching.
Pattern String requiredposition: 1pipeline: False
Regular expression pattern to find in table cells.

Outputs

OfficeIMO.Word.WordTable

Find-OfficeWordTable [-CaseSensitive] -Document <WordDocument> [-IncludeNested] -Text <String> [<CommonParameters>]
#
Parameter set: DocumentText

Parameters

CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching.
Document WordDocument requiredposition: namedpipeline: True (ByValue)
Open document to inspect. The caller controls the document lifetime.
IncludeNested SwitchParameter optionalposition: namedpipeline: False
Include nested tables inside table cells.
Text String requiredposition: 1pipeline: False
Literal text to find in table cells.

Outputs

OfficeIMO.Word.WordTable

Find-OfficeWordTable [-CaseSensitive] -Document <WordDocument> [-IncludeNested] -Pattern <String> [<CommonParameters>]
#
Parameter set: DocumentRegex

Parameters

CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching.
Document WordDocument requiredposition: namedpipeline: True (ByValue)
Open document to inspect. The caller controls the document lifetime.
IncludeNested SwitchParameter optionalposition: namedpipeline: False
Include nested tables inside table cells.
Pattern String requiredposition: 1pipeline: False
Regular expression pattern to find in table cells.

Outputs

OfficeIMO.Word.WordTable