margin Property

Microsoft FrontPage Visual Basic

margin Property

Returns or sets a String that represents the width of the top, bottom, left, and right margins for the specified object. Corresponds to the margin property of an inline style attribute.

expression.margin

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

Remarks

The String for the margin property can be one or more of the following values:

Value Description
auto Value of all margins is the same as the default setting.

The following code sets all margins in the active document to the same default setting.

ActiveDocument.body.Style.margin = "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).

You can set all margins to the same measurement. For example, the following code sets the all margins margin property of the active document to 50 pixels. This setting affects all margins.

ActiveDocument.body.Style.margin = "50px"

You can set each margin separately by specifying a measurement for each of the four margins. Using a space to separate the individual measurements, specify the margin settings starting with the top margin and working clockwise. For example, the following code sets the top margin to 50 pixels, the right margin to 10 pixels, the bottom margin to 100 pixels, and the left margin to 0 pixels.

ActiveDocument.body.Style.margin = "50px 10px 100px 0px"
percentage Integer, followed by a %. The value is a percentage of the width (for left and right margins) or height (for top and bottom margins) of the parent object.

The following code sets all margins to 10 percent of the width or height of the browser window.

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

The following code sets the top margin to 10 percent of the height of the browser window, the right margin to 20 percent of the width of the browser window, the bottom margin to 30 percent of the height of the browser window, and the left margin to 40 percent of the width of the browser window.

ActiveDocument.body.Style.margin = "10% 20% 30%, 40%"

In addition to specifying all margin settings at the same time, you can mix and match the above measurements as necessary. For example, the following code sets the top margin to 10 pixels, the right margin to five percent of the width of the browser window, the bottom margin to the default setting for the document, and the left margin to one and a half inches.

    ActiveDocument.body.Style.margin = "10px 5% auto 1.5in"