API Reference

Cmdlet

Update-OfficeWordTableOfContents

Namespace PSWriteOffice
Inputs
OfficeIMO.Word.WordTableOfContent OfficeIMO.Word.WordDocument
Outputs
OfficeIMO.Word.WordTableOfContent

Updates the table of contents in a Word document.

Remarks

Updates the table of contents in a Word document.

Examples

Authored help example

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: Document

Parameters

Document WordDocument optionalposition: namedpipeline: True (ByValue)
Document to update when provided explicitly.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the updated table of contents.
Regenerate SwitchParameter optionalposition: namedpipeline: False
Rebuild the table of contents before updating.

Outputs

OfficeIMO.Word.WordTableOfContent

Update-OfficeWordTableOfContents [-PassThru] [-Regenerate] [-TableOfContents <WordTableOfContent>] [<CommonParameters>]
#
Parameter set: TableOfContents

Parameters

PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the updated table of contents.
Regenerate SwitchParameter optionalposition: namedpipeline: False
Rebuild the table of contents before updating.
TableOfContents WordTableOfContent optionalposition: namedpipeline: True (ByValue)
Table of contents to update.

Outputs

OfficeIMO.Word.WordTableOfContent