marginTop Property

Microsoft FrontPage Visual Basic

marginTop Property

Returns or sets a String that represents the width of the top margin for the specified object. Corresponds to the marginTop property of an inline style attribute.

expression.MarginTop

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

Remarks

The String for the marginTop property can be one of the following values:

Value Description
auto Bottom margin measurement is the default setting.

The following code sets the top margin in the active document to the default setting.

ActiveDocument.body.Style.marginTop = "auto"
width Floating-point number, followed by an absolute units designator (cm, mm, in, pt, pc, or px) or a relative units designator (em or ex).

The following code sets the top margin of the active document to 50 pixels.

ActiveDocument.body.Style.marginTop = "50px"
percentage Integer, followed by a %. The value is a percentage of the height of the parent object.

The following code sets the top margin to 10 percent of the height of the browser window.

ActiveDocument.body.Style.marginTop = "10%"

You can also use the margin property to set all margins at the same time. For example, the following code does the same as the example below but uses the margin property.

    ActiveDocument.body.Style.margin = "auto 25px 2px 50px"
  

Example

The following example sets the top, right, bottom, and left margins for the active document.

    With ActiveDocument.body.Style
    .MarginTop = "auto"
    .MarginRight = "25px"
    .MarginBottom = "1%"
    .MarginLeft = "50px"
End With