background Property

Microsoft FrontPage Visual Basic

background Property

Sets or returns a String that represents up to five separate background properties of a specified object.

expression.background

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

Use the background property to set one, all, or any of the values of the background properties at one time. The background property can specify values for up to five of the following space-delimited items, in any order:

color Any value available to the backgroundColor property.
image Any value available to the backgroundImage property. When you use the background property to specify a background image, surround the image filename with "url" and parentheses. For example, url(graphics/image.gif).
repeat Any value available to the backgroundRepeat property.
attachment Any value available to the backgroundAttachment property.
position Any value available to the backgroundPosition property.

Example

The following example sets the background color or image for the body of the specified document. The strBackground argument can be a color name, a Red-Green-Blue (RGB) color, the path to an image file, or a string specifying any or all of the preceding space-delimited items.

    Function SetBackground(objDoc As FPHTMLDocument, _
        strBackground As String) As Boolean

    On Error GoTo SetBackgroundError

    objDoc.body.Style.Background = strBackground
    SetBackground = True

ExitSetBackground:
    Exit Function
    
SetBackgroundError:
    SetBackground = False
    GoTo ExitSetBackground
End Function
  

Use the following example to call the preceding function. This example assumes that you have an image file called "picture.jpg" located in the same directory as the specified document.

    Sub CallSetBackground()
    MsgBox SetBackground(ActiveDocument, _
        "url(picture.jpg) no-repeat")
End Sub