Cmdlet
Get-OfficeWordTableOfContents
Gets the table of contents from a Word document.
Syntax
Examples
Read a table of contents before updating it.
$doc = Get-OfficeWord -Path .\Report.docx
$toc = $doc | Get-OfficeWordTableOfContents
if ($toc) {
$toc | Set-OfficeWordTableOfContents -Text 'Contents' -TextNoContent 'No entries' -PassThru
$doc | Save-OfficeWord -Path .\Report-Toc.docx
}Gets the TOC from an open document, updates it, and saves a variant.
Parameters
- -Path String
- Path to the .docx file.
- -Document WordDocument
- Word document to read.
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.