Share via


PageBackground Object

Publisher Developer Reference

Represents the background of a page.

Example

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.

Visual Basic for Applications
  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.

Visual Basic for Applications
  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.

Visual Basic for Applications
  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.)

Visual Basic for Applications
  ActiveDocument.Pages(1).Background.Delete

See Also