# Close-Document Closes an open document. ## Syntax ```{code-block} PowerShell :linenos: Close-Document [-Save] [-Document ] [] ``` ## Parameters | Type | Name | Description | Optional | | ------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------- | -------- | | {ref}`IDocument ` | Document | The cmdlet will close this document. Otherwise, the last opened document will be closed | yes | | Boolean | Save | The application will save the document on close | yes | ## Return type **Bool**: on success the cmdlet returns \$true otherwise \$false.\ \$result.Error \<- The result has additionally an Error property which contains the Exception object\ \$result.Application \<- Application is an implementation of IApplication\ \$result.Document \<- Document is an implementation of IDocument ## Remarks After all documents got closed in {ref}`Inventor ` or {ref}`InventorServer `, the active project file will be resetet to the original project file. ## Examples **Closing the last opened document** ```{code-block} PowerShell :linenos: Open-Document -localFile 'C:\Vault\Test.ipt' Close-Document ``` **Closing a specific document** ```{code-block} PowerShell :linenos: $open1 = Open-Document -localFile 'C:\Vault\Test.ipt' $open2 = Open-Document -localFile 'C:\Vault\Test.ipt' Close-Document -Document $open1.Document ``` **Checking if document was closed successfully** ```{code-block} PowerShell :linenos: $result = Close-Document if(-not $result) { throw "Failed to save and close document with error: ". $result.Error.Message } ``` **Close and Save document** ```{code-block} PowerShell :linenos: $openResult = Open-Document -localFile 'C:\Vault\Test.ipt' ... Close-Document -Document $openResult.Document -Save $true ``` **Using the close result** ```{code-block} PowerShell :linenos: $result = Close-Document if($result.Application.Name -eq 'Inventor') { $result.Application.Instance.Visible = $true } ```