API Reference
Set-OfficeWordBackground
Sets the background for a Word document.
Remarks
Sets the background for a Word document.
Examples
Apply a solid background color while composing a report.
PS>
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.
PS>
$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.
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.
Syntax
Set-OfficeWordBackground -Color <String> [-Document <WordDocument>] [-PassThru] [<CommonParameters>]#ColorParameters
- Color String
- Background color. Named colors and hexadecimal values are accepted.
- Document WordDocument
- Document to update when provided explicitly.
- PassThru SwitchParameter
- Emit the updated document.
Outputs
OfficeIMO.Word.WordDocument
Set-OfficeWordBackground [-Document <WordDocument>] [-Height <Double>] -ImagePath <String> [-PassThru] [-Width <Double>] [<CommonParameters>]#ImageParameters
- Document WordDocument
- Document to update when provided explicitly.
- Height Double
- Optional background image height in pixels.
- ImagePath String
- Path to the background image.
- PassThru SwitchParameter
- Emit the updated document.
- Width Double
- Optional background image width in pixels.
Outputs
OfficeIMO.Word.WordDocument