Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

New-OfficeOpenDocument

Module
PSWriteOffice
Inputs
None
Outputs
OfficeIMO.OpenDocument.OdfDocument System.IO.FileInfo

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>]
#
Parameter set: Live
New-OfficeOpenDocument
[-AllowLoss]
[-Content] <ScriptBlock>
[-Force]
[-Kind <Text|Spreadsheet|Presentation|Graphics>]
[-PassThru]
[-Path] <String>
[-Show]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
#
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.

Examples

Create a text report and save the completed block.

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.

$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.