API Reference
Cmdlet
Update-OfficeWordTableOfContents
Updates the table of contents in a Word document.
Remarks
Updates the table of contents in a Word document.
Examples
Mark table of contents for refresh on open.
PS>
New-OfficeWord -Path .\ExecutiveReport.docx {
Add-OfficeWordTableOfContents
Add-OfficeWordParagraph -Text 'Executive summary' -Style Heading1
Add-OfficeWordParagraph -Text 'Summary text'
Update-OfficeWordTableOfContents
}
Marks TOC fields as dirty and updates the document settings so Word refreshes the TOC when opened.
Regenerate a TOC in an existing document object.
PS>
$doc = Get-OfficeWord -Path .\Report.docx
$doc | Update-OfficeWordTableOfContents -Regenerate
$doc | Save-OfficeWord -Path .\Report-RegeneratedToc.docx
Uses OfficeIMO's regenerate path, then saves the updated 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
Update-OfficeWordTableOfContents [-Document <WordDocument>] [-PassThru] [-Regenerate] [<CommonParameters>]#Parameter set:
DocumentParameters
- Document WordDocument
- Document to update when provided explicitly.
- PassThru SwitchParameter
- Emit the updated table of contents.
- Regenerate SwitchParameter
- Rebuild the table of contents before updating.
Outputs
OfficeIMO.Word.WordTableOfContent
Update-OfficeWordTableOfContents [-PassThru] [-Regenerate] [-TableOfContents <WordTableOfContent>] [<CommonParameters>]#Parameter set:
TableOfContentsParameters
- PassThru SwitchParameter
- Emit the updated table of contents.
- Regenerate SwitchParameter
- Rebuild the table of contents before updating.
- TableOfContents WordTableOfContent
- Table of contents to update.
Outputs
OfficeIMO.Word.WordTableOfContent