# New-OfficeOpenDocument

Creates an ODT, ODS, ODP or ODG model, returning it live or saving a completed content block.

Cmdlet 

**Module**

`PSWriteOffice`

**Inputs**

`None`

**Outputs**

`OfficeIMO.OpenDocument.OdfDocument` `System.IO.FileInfo`

**Source**

[NewOfficeOpenDocumentCommand.cs:21](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/OpenDocument/NewOfficeOpenDocumentCommand.cs#L21) 

Creates an ODT, ODS, ODP or ODG model, returning it live or saving a completed content block.

## Syntax

```
New-OfficeOpenDocument
[-Force]
[-Kind <Text|Spreadsheet|Presentation|Graphics>]
[[-Path] <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
```

[#](#method-new-officeopendocument-switchparameter-odfdocumentkind-string-switchparameter-switchparameter)

Parameter set: `Live`

```
New-OfficeOpenDocument
[-AllowLoss]
[-Content] <ScriptBlock>
[-Force]
[-Kind <Text|Spreadsheet|Presentation|Graphics>]
[-PassThru]
[-Path] <String>
[-Show]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
```

[#](#method-new-officeopendocument-switchparameter-scriptblock-switchparameter-odfdocumentkind-switchparameter-string-switchparameter-switchparameter-switchparameter)

Parameter set: `Content`

## Description

Kind is inferred from Path when omitted. Without a block no file is written. A block publishes only after success; an existing destination requires Force.

## Guides & Samples

Authored walkthroughs and practical samples linked to this command.

- [Open Formats and Text Automation](/docs/pswriteoffice/open-text-formats/) Guide
  
  Use the smaller PSWriteOffice families for text, interchange, open formats, and managed message workflows. Includes examples and cmdlet links.
- [Create and Read ODT, ODS and ODP Files](/docs/open-document/create-read/) Guide
  
  Create OpenDocument text, spreadsheet and presentation files, read their content, edit them in place, and open password-protected files.
- [OpenDocument](/docs/open-document/) Guide
  
  Create, read and edit ODT, ODS and ODP files in .NET without LibreOffice, and convert them to Word, Excel, PowerPoint and PDF with a report of anything lost.

## Examples

### Create a text report and save the completed block.

```powershell
New-OfficeOpenDocument -Path ./Report.odt {
    Add-OfficeOpenDocumentHeading -Text 'Service report' -Level 1
    Add-OfficeOpenDocumentParagraph -Text 'All services are available.'
}
```

### Create a live drawing and save it explicitly.

```powershell
$drawing = New-OfficeOpenDocument -Path ./Overview.odg
$page = $drawing.AddPage('Overview')
Save-OfficeOpenDocument -Document $drawing
```

## Parameters

**-Force SwitchParameter optional**

Allow a completed content block to replace an existing destination.

**-Kind OdfDocumentKind optional**

Document kind; required when no destination extension is supplied.

Possible values: `Text`, `Spreadsheet`, `Presentation`, `Graphics`

**-Path String required in Contentposition: 0aliases: FilePath**

Optional associated destination for a live document; required when a content block saves a file.

**-WhatIf SwitchParameter optional**

Shows what would happen if the command runs.

**-Confirm SwitchParameter optional**

Prompts for confirmation before running the command.

**-AllowLoss SwitchParameter optionalsets: Content**

Explicitly accept reductions reported by the content block's native save.

**-Content ScriptBlock requiredposition: 1sets: Content**

Authoring block to complete before the document is atomically saved and closed.

**-PassThru SwitchParameter optionalsets: Content**

Return the saved FileInfo after a completed content block.

**-Show SwitchParameter optionalsets: Content**

Open the saved result in its registered application after the content block succeeds.

## 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).

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