Evotec

Project

PSWriteOffice

PSWriteOffice is an open-source PowerShell and .NET project with packages, release history, and technical documentation.

Stars 144
Forks 12
Open issues 16
PowerShell Gallery downloads 150,904
Release v0.2.0
Language: C# Updated: 2026-04-06

API Reference

Cmdlet

Close-OfficeExcel

Namespace PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Object

Closes an Excel workbook and optionally saves it.

Remarks

Convenience wrapper so scripts do not need to call Save or Dispose directly.

Examples

Authored help example

Save to a new path and open the file.

PS>


Close-OfficeExcel -Document $workbook -Save -Path .\report-final.xlsx -Show
        

Saves pending changes to a new file, launches Excel, and releases the workbook.

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-OfficeExcel -Document <ExcelDocument> [-Path <String>] [-Save] [-Show] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Parameters

Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to close.
Path String optionalposition: namedpipeline: False
Optional output path when saving.
Save SwitchParameter optionalposition: namedpipeline: False
Persist changes before closing.
Show SwitchParameter optionalposition: namedpipeline: False
Open the workbook in Excel after saving.

Outputs

System.Object