Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficeWordTableRow

Module PSWriteOffice
Inputs
OfficeIMO.Word.WordTable
Outputs
OfficeIMO.Word.WordTableRow

Appends a row to an existing Word table.

Syntax

Add-OfficeWordTableRow [-PassThru] [-Table] <WordTable> [[-Values] <Object>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Adds a new row to a WordTable that was already created or found in an existing document. The command accepts scalar values, arrays, dictionaries, ordered dictionaries, and PowerShell objects. Values are expanded from left to right across cells; missing values become empty cells. This keeps existing-document editing simple without forcing callers back into the Word DSL.

Examples

Authored help example

Append values to the first table.

$doc = Get-OfficeWord -Path .\Report.docx
$doc | Get-OfficeWordTable | Select-Object -First 1 |
    Add-OfficeWordTableRow -Values 'Service', 'Ready', 'Low'

Adds one table row and writes the supplied values into its cells.

Append an object-like row to a table found by marker text.

$doc = Get-OfficeWord -Path .\Report.docx
$table = Find-OfficeWordTable -Document $doc -Text 'Risk marker' | Select-Object -First 1
$table | Add-OfficeWordTableRow -Values ([ordered]@{
    Item  = 'Mitigation plan'
    Owner = 'Service Desk'
    State = 'Ready'
})
$doc | Close-OfficeWord -Save

Uses an ordered dictionary so values are written into predictable table columns.

Parameters

-PassThru SwitchParameter optional
Emit the created row for additional OfficeIMO-level edits.
-Table WordTable requiredposition: 0pipeline: True (ByValue)
Existing Word table to append to, usually from Get-OfficeWordTable or Find-OfficeWordTable.
-Values Object optionalposition: 1aliases: Data, InputObject
Values to write into the new row. Arrays, dictionaries, ordered dictionaries, and objects are expanded across cells.

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.