PageBackground object (Publisher)
Represents the background of a page.
Remarks
Use the Background property of a Page object to return a PageBackground object.
Use the Exists property to determine if a background already exists for the specified Page object.
Use the Fill property to return a FillFormat object.
Use the Delete method to delete a background for the specified page.
Example
The following example creates a PageBackground object and sets it to the background of the first page of the active document.
Dim objPageBackground As PageBackground
Set objPageBackground = ActiveDocument.Pages(1).Background
The following example builds upon the previous example. First a PageBackground object is created and set to the background of the first page of the active document. Next, a test is made to check if a background exists for the page already. If not, one is created by calling the Create method of the PageBackground object.
Dim objPageBackground As PageBackground
Set objPageBackground = ActiveDocument.Pages(1).Background
If objPageBackground.Exists = False Then
objPageBackground.Create
End If
The following example builds upon the previous example. First a PageBackground object is created and set to the background of the first page of the active document. Next, a test is made to check if a background exists for the page already. If not, one is created by calling the Create method of the PageBackground object. A FillFormat object is returned by using the Fill property of the PageBackground object. A few of the available properties of the FillFormat object are then set.
Dim objPageBackground As PageBackground
Dim objFillFormat As FillFormat
Set objPageBackground = ActiveDocument.Pages(1).Background
If objPageBackground.Exists = False Then
objPageBackground.Create
End If
Set objFillFormat = objPageBackground.Fill
With objFillFormat
.BackColor.RGB = RGB(Red:=0, GReen:=155, Blue:=99)
.ForeColor.RGB = RGB(Red:=155, GReen:=234, Blue:=0)
.TwoColorGradient msoGradientDiagonalDown, 4
End With
The following example deletes the background of the first page in the active document. This example assumes that the specified page has an existing background. A run-time error occurs if the page does not contain a background.
ActiveDocument.Pages(1).Background.Delete
Methods
Properties
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.