Align Method

Microsoft Publisher Visual Basic

expression.Align(AlignCmd, RelativeTo)

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

AlignCmd   Required MsoAlignCmd. Specifies how the shapes are to be aligned.

MsoAlignCmd can be one of these MsoAlignCmd constants.
msoAlignBottoms Aligns shapes along their bottom edges. If RelativeTo is msoFalse, the bottommost shape determines the line against which the other shapes are aligned.
msoAlignCenters Aligns shapes on a vertical line through their centers. If RelativeTo is msoFalse, shapes are aligned on a line halfway between the left- and rightmost shapes.
msoAlignLefts Aligns shapes along their left edges. If RelativeTo is msoFalse, the leftmost shape determines the line against which the other shapes are aligned.
msoAlignMiddles Aligns shapes on a horizontal line through their centers. If RelativeTo is msoFalse, shapes are aligned on a line halfway between the top- and bottommost shapes.
msoAlignRights Aligns shapes along their right edges. If RelativeTo is msoFalse, the rightmost shape determines the line against which the other shapes are aligned.
msoAlignTops Aligns shapes along their top edges. If RelativeTo is msoFalse, the topmost shape determines the line against which the other shapes are aligned.

RelativeTo   Required MsoTriState. Specifies whether shapes are aligned relative to the page or to one another.

MsoTriState can be one of these MsoTriState constants.
msoCTrue Not used with this method.
msoFalse Aligns shapes relative to one another.
msoTriStateMixed Not used with this method.
msoTriStateToggle Not used with this method.
msoTrue Aligns shapes relative to the page.

Remarks

If the RelativeTo argument is msoFalse and the shape range contains only one shape, an error occurs.

Example

The following example aligns all the shapes on the first page of the active publication on a vertical line through their centers.

ActiveDocument.Pages(1).Shapes.Range.Align _
    AlignCmd:=msoAlignCenters, _
    RelativeTo:=msoTrue