OfficeIMO

API Reference

Command

Close-OfficeWord

Namespace PSWriteOffice
Inputs
OfficeIMO.Word.WordDocument
Outputs
System.Object

Closes a Word document, optionally saving it.

Remarks

Closes a Word document, optionally saving it.

Examples

Close without saving.


PS>$doc = Get-OfficeWord -Path .\Report.docx; Close-OfficeWord -Document $doc
        

Disposes the loaded document instance without saving changes.

Save to a new path and open the file.


PS>Close-OfficeWord -Document $doc -Save -Path .\Report-final.docx -Show
        

Saves updates to Report-final.docx, opens it, and disposes 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

Close-OfficeWord -Document <WordDocument> [-Path <String>] [-Save] [-Show] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Parameters

Document WordDocument requiredposition: 0pipeline: True (ByValue)
Word document to close.
Path String optionalposition: namedpipeline: False
Optional target path when saving.
Save SwitchParameter optionalposition: namedpipeline: False
Persist changes before closing.
Show SwitchParameter optionalposition: namedpipeline: False
Open the file after saving.

Outputs

System.Object