Project

PSWriteOffice

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

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Set-OfficeWordBackground

Module
PSWriteOffice
Inputs
OfficeIMO.Word.WordDocument
Outputs
OfficeIMO.Word.WordDocument

Sets the background for a Word document.

Syntax

Set-OfficeWordBackground
[-Color] <String>
[-Document <WordDocument>]
[-PassThru]
[<CommonParameters>]
#
Parameter set: Color
Set-OfficeWordBackground
[-Document <WordDocument>]
[-Height <Double>]
[-ImagePath] <String>
[-PassThru]
[-Width <Double>]
[<CommonParameters>]
#
Parameter set: Image

Examples

Apply a solid background color while composing a report.

New-OfficeWord -Path .\BrandedReport.docx {
    Set-OfficeWordBackground -Color '#f4f7fb'
    Add-OfficeWordParagraph -Text 'Executive summary'
}

Sets the document background to the provided hex color and continues normal document composition.

Apply an image background to an existing document.

$doc = Get-OfficeWord -Path .\Draft.docx
$doc | Set-OfficeWordBackground -ImagePath .\Assets\Background.png -Width 600 -Height 800 -PassThru |
    Save-OfficeWord -Path .\Draft-Branded.docx

Uses OfficeIMO.Word background image support and saves the updated document through the standard save cmdlet.

Parameters

-Color String requiredposition: 0sets: Color
Background color. Named colors and hexadecimal values are accepted.
-Document WordDocument optionalpipeline: True (ByValue)
Document to update when provided explicitly.
-PassThru SwitchParameter optional
Emit the updated document.
-Height Double optionalsets: Image
Optional background image height in pixels.
-ImagePath String requiredposition: 0sets: Image
Path to the background image.
-Width Double optionalsets: Image
Optional background image width in pixels.

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.