Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeWordBackground

Aliases: WordBackground
Module
PSWriteOffice
Aliases
WordBackground
Inputs
OfficeIMO.Word.WordDocument
Outputs
OfficeIMO.Word.WordDocument

Sets the background for a Word document.

Syntax

Set-OfficeWordBackground
[-Color] <OfficeColor>
[-Document <WordDocument>]
[-PassThru]
[<CommonParameters>]
#
Parameter set: Color
Set-OfficeWordBackground
[-Document <WordDocument>]
[-Height <OfficeLength>]
[-ImagePath] <String>
[-PassThru]
[-Width <OfficeLength>]
[<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 = Open-OfficeWord -Path .\Draft.docx
$doc | Set-OfficeWordBackground -ImagePath .\Assets\Background.png -Width 600px -Height 800px -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 OfficeColor 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 OfficeLength optionalsets: Image
Optional background image height; numbers mean points.
-ImagePath String requiredposition: 0sets: Image
Path to the background image.
-Width OfficeLength optionalsets: Image
Optional background image width; numbers mean points.

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.