Skip to main content
OfficeIMO Docs Search documentation/

Migrate from PSWriteWord to PSWriteOffice

Edit on GitHub

Replace archived PSWriteWord scripts with maintained PSWriteOffice Word commands for DOCX creation, editing, review, merge, and conversion.

PSWriteWord is archived and replaced by PSWriteOffice. New development should use the OfficeWord command family, which runs on the current OfficeIMO.Word engine without requiring Microsoft Word.

PSWriteOffice is not a drop-in namespace change. PSWriteWord exposed Xceed-era objects and the Documentimo DSL; PSWriteOffice uses OfficeIMO objects and a scoped document DSL. Rewrite the composition block and validate templates, styles, fields, headers, footers, and pagination with representative documents.

Common command replacements

PSWriteWordPSWriteOfficeMigration note
New-WordDocumentNew-OfficeWordPrefer the script-block DSL when creating a complete document.
Get-WordDocumentGet-OfficeWordUse targeted Get-OfficeWord* commands to inspect content.
Add-WordParagraph, Add-WordTextAdd-OfficeWordParagraph, Add-OfficeWordTextText runs can be added inside an active paragraph context.
Add-WordTableAdd-OfficeWordTablePass objects with -InputObject; map old design names to current table styles.
Add-WordPictureAdd-OfficeWordImageRecheck sizing, wrapping, and placement.
Add-WordHeader, Add-WordFooterAdd-OfficeWordHeader, Add-OfficeWordFooterConfigure them inside the appropriate section.
Add-WordListAdd-OfficeWordListNested list behavior should be verified against the generated DOCX.
Add-WordTOCAdd-OfficeWordTableOfContentsUse update commands when fields or headings change.
Merge-WordDocumentJoin-OfficeWordDocumentSupply a base input and one or more append paths.
Save-WordDocumentSave-OfficeWordNew-OfficeWord saves automatically unless -NoSave is used.
Documentimo, DocText, DocTableNew-OfficeWord with Add-OfficeWord* commandsRewrite the old DSL; aliases are available for interactive use, but canonical names are clearer in maintained scripts.

Before: PSWriteWord

$document = New-WordDocument -FilePath '.\Output\Status.docx'
Add-WordText -WordDocument $document -Text 'Service status'
Add-WordTable -WordDocument $document -DataTable $services
Save-WordDocument -WordDocument $document

After: PSWriteOffice

$services = Get-Service |
    Select-Object -First 10 Name, Status

New-OfficeWord -Path '.\Output\Status.docx' {
    Add-OfficeWordSection {
        Add-OfficeWordParagraph -Text 'Service status' -Style Heading1
        Add-OfficeWordTable -InputObject $services -Style 'GridTable1LightAccent2'
    }
}

For an existing file, load it with Get-OfficeWord, make targeted changes, and pipe the returned document to Save-OfficeWord. Use Compare-OfficeWordDocument when the migration needs machine-readable evidence of document changes.

Validate before replacing the old job

  • compare page setup, section breaks, styles, lists, tables, images, and headers or footers;
  • check fields and table-of-contents updates in the target Word viewer;
  • verify password protection and template behavior explicitly;
  • test charts, equations, content controls, comments, revisions, and mail merge when the old workflow used them.

See Word automation and the generated PowerShell command reference for current syntax.