Share via


PageBackground Object [Publisher 2003 VBA Language Reference]

Page
PageBackground
FillFormat

Represents the background of a page.

Using the PageBackground Object

Use the Background property of a Page object to return a PageBackground object. 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
    

Use PageBackground.Exists to determine if a background already exists for the specified Page object. 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. Then a test is made to check if a background exists for the page already. If not then 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
    

Use PageBackground.Fill to return a FillFormat object. 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. Then a test is made to check if a background exists for the page already. If not then 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
    

Use PageBackground.Delete to delete a background for the specified page. The following example deletes the background of the first page in the active document. (The following example assumes 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

Properties | Application Property | Exists Property | Fill Property | Parent Property

Methods | Create Method | Delete Method

Parent Objects | Page Object

Child Objects | FillFormat Object