# Close-OfficeWord

Closes one or more tracked Word documents, optionally saving them.

Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

[View on GitHub](https://github.com/EvotecIT/OfficeIMO/tree/master/PowerShell/PSWriteOffice) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteOffice/releases/tag/v3.0.5) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteOffice/0.2.0)

Stars **727**

Forks **84**

Open issues **7**

Total downloads **5,275,783**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-24

Cmdlet 

**Module**

`PSWriteOffice`

**Inputs**

`OfficeIMO.Word.WordDocument`

**Source**

[CloseOfficeWordCommand.cs:28](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Word/CloseOfficeWordCommand.cs#L28) 

Closes one or more tracked Word documents, optionally saving them.

## Syntax

```
Close-OfficeWord
[-Current]
[-Open]
[-Password <String>]
[-Path <String>]
[-Save]
[<CommonParameters>]
```

[#](#method-close-officeword-switchparameter-switchparameter-string-string-switchparameter)

Parameter set: `Current`

```
Close-OfficeWord
[-Document] <WordDocument>
[-Open]
[-Password <String>]
[-Path <String>]
[-Save]
[<CommonParameters>]
```

[#](#method-close-officeword-worddocument-switchparameter-string-string-switchparameter)

Parameter set: `Document`

```
Close-OfficeWord
-All
[-Open]
[-Password <String>]
[-Save]
[<CommonParameters>]
```

[#](#method-close-officeword-switchparameter-switchparameter-string-switchparameter)

Parameter set: `All`

## Description

Provides a cmdlet wrapper for WordDocument.Dispose/Save so scripts need not call .NET methods directly.

## Examples

### Close without saving.

```powershell
$doc = Get-OfficeWord -Path .\Report.docx; Close-OfficeWord -Document $doc
```

Disposes the loaded document instance without saving changes.

### Close the most recently tracked document.

```powershell
Close-OfficeWord
```

Closes the current tracked document when a document handle is not passed explicitly.

### Save to a new path and open the file.

```powershell
Close-OfficeWord -Document $doc -Save -Path .\Report-final.docx -Open
```

Saves updates to Report-final.docx, opens it, and disposes the document.

## Parameters

**-Current SwitchParameter optionalsets: Current**

Close the most recently tracked document.

**-Open SwitchParameter optionalaliases: Show**

Open the file after saving. Requires -Save or -Path.

**-Password String optional**

Password used to save the document as an encrypted package.

**-Path String optionalsets: Current, Document**

Optional target path when saving.

**-Save SwitchParameter optional**

Persist changes before closing.

**-Document WordDocument requiredposition: 0pipeline: True (ByValue)sets: Document**

Word document to close.

**-All SwitchParameter requiredsets: All**

Close all tracked documents for the current runspace.

## 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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:AB6B7717B34C9F8BAC6B3E5120516D2E43F3B409E6A7392F99865146C4D2E01D -->
