API Reference
Cmdlet
Set-OfficeWordTableOfContents
Sets properties on a table of contents in a Word document.
Remarks
Sets properties on a table of contents in a Word document.
Examples
Customize table of contents text during composition.
PS>
New-OfficeWord -Path .\Report.docx {
Add-OfficeWordTableOfContents
Set-OfficeWordTableOfContents -Text 'Contents' -TextNoContent 'No entries yet'
Add-OfficeWordParagraph -Text 'Executive summary' -Style Heading1
Update-OfficeWordTableOfContents
}
Updates TOC display text, adds heading content, and marks the TOC for refresh.
Update an existing TOC object from a document.
PS>
$doc = Get-OfficeWord -Path .\Report.docx
$doc |
Get-OfficeWordTableOfContents |
Set-OfficeWordTableOfContents -Text 'Report contents'
$doc | Save-OfficeWord -Path .\Report-Toc.docx
Pipes the OfficeIMO TOC object into the thin setter and saves the 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
Set-OfficeWordTableOfContents [-PassThru] [-TableOfContents <WordTableOfContent>] [-Text <String>] [-TextNoContent <String>] [<CommonParameters>]#Parameter set:
TableOfContentsParameters
- PassThru SwitchParameter
- Emit the updated table of contents.
- TableOfContents WordTableOfContent
- Table of contents to update.
- Text String
- Heading text for the table of contents.
- TextNoContent String
- Text shown when the table of contents has no entries.
Outputs
OfficeIMO.Word.WordTableOfContent
Set-OfficeWordTableOfContents [-Document <WordDocument>] [-PassThru] [-Text <String>] [-TextNoContent <String>] [<CommonParameters>]#Parameter set:
DocumentParameters
- Document WordDocument
- Document to update when provided explicitly.
- PassThru SwitchParameter
- Emit the updated table of contents.
- Text String
- Heading text for the table of contents.
- TextNoContent String
- Text shown when the table of contents has no entries.
Outputs
OfficeIMO.Word.WordTableOfContent