API Reference
Cmdlet
Get-OfficeWordTableOfContents
Gets the table of contents from a Word document.
Remarks
Gets the table of contents from a Word document.
Examples
Read a table of contents before updating it.
PS>
$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.
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
Get-OfficeWordTableOfContents -InputPath <String> [<CommonParameters>]#Parameter set:
PathParameters
- InputPath String
- Path to the .docx file.
Outputs
OfficeIMO.Word.WordTableOfContent
Get-OfficeWordTableOfContents -Document <WordDocument> [<CommonParameters>]#Parameter set:
DocumentParameters
- Document WordDocument
- Word document to read.
Outputs
OfficeIMO.Word.WordTableOfContent