Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Get-OfficeWordList

Module PSWriteOffice
Inputs
OfficeIMO.Word.WordDocument OfficeIMO.Word.WordSection
Outputs
OfficeIMO.Word.WordList

Gets lists from a Word document or section.

Syntax

Get-OfficeWordList [-IncludeEmpty] [-Path] <String> [<CommonParameters>]
#
Parameter set: Path
Get-OfficeWordList -Document <WordDocument> [-IncludeEmpty] [<CommonParameters>]
#
Parameter set: Document
Get-OfficeWordList [-IncludeEmpty] -Section <WordSection> [<CommonParameters>]
#
Parameter set: Section

Description

Returns existing WordList objects so scripts can inspect list items, report on checklist content, or pipe a selected list to Add-OfficeWordListItem. Use this command when the script needs to work with list objects directly instead of using a text search first.

Examples

Authored help example

Inspect existing list items.

$doc = Get-OfficeWord -Path .\Report.docx
$list = $doc | Get-OfficeWordList | Select-Object -First 1
$list.ListItems | Select-Object -Property Text

Returns OfficeIMO list objects so existing list items can be reviewed or appended to.

Select a checklist by existing item text and append an item.

$doc = Get-OfficeWord -Path .\Report.docx
Get-OfficeWordList -Document $doc |
    Where-Object { $_.ListItems.Text -contains 'Initial review' } |
    Add-OfficeWordListItem -Text 'Final approval'
$doc | Close-OfficeWord -Save

Inspects list objects directly when the caller wants custom selection logic.

Parameters

-IncludeEmpty SwitchParameter optional
Include numbering definitions that do not currently have list items.
-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path
Path to the document to open read-only for list inspection.
-Document WordDocument requiredpipeline: True (ByValue)sets: Document
Open document to inspect. The caller controls the document lifetime.
-Section WordSection requiredpipeline: True (ByValue)sets: Section
Section to inspect when the caller only wants lists in a specific section.

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.