SetLeftIndent Method

Microsoft Word Visual Basic

SetLeftIndent Method

       

Sets the indentation for a row or rows in a table.

expression.SetLeftIndent(LeftIndent, RulerStyle)

expression   Required. An expression that returns a Row or Rows object.

LeftIndent   Required Single. The distance (in points) between the current left edge of the specified row or rows and the desired left edge.

RulerStyle  Required WdRulerStyle. Controls the way Word adjusts the table when the left indent is changed.

WdRulerStyle can be one of these WdRulerStyle constants.
wdAdjustNone Adjusts the left edge of row or rows, preserving the width of all columns by shifting them to the left or right. This is the default value.
wdAdjustSameWidth Adjusts the left edge of the first column, preserving the position of the right edge of the table by setting the widths of all the cells in the specified row or rows to the same value.
wdAdjustFirstColumn Adjusts the left edge of the first column only, preserving the positions of the other columns and the right edge of the table.
wdAdjustProportional Adjusts the left edge of the first column, preserving the position of the right edge of the table by proportionally adjusting the widths of all the cells in the specified row or rows.

Remarks

The WdRulerStyle behavior described above applies to left-aligned tables. The WdRulerStyle behavior for center- and right-aligned tables can be unexpected; in these cases, the SetLeftIndent method should be used with care.

Example

This example creates a table in a new document and indents the first row 0.5 inch (36 points). When you change the left indent, the cell widths are adjusted to preserve the right edge of the table.

Dim docNew As Document
Dim tableNew As Table

Set docNew = Documents.Add
Set tableNew = docNew.Tables.Add(Range:=Selection.Range, _
    NumRows:=3, NumColumns:=3)

tableNew.Rows(1).SetLeftIndent LeftIndent:=InchesToPoints(0.5), _
    RulerStyle:=wdAdjustSameWidth

This example indents the first row in table one in the active document 18 points, and it narrows the width of the first column to preserve the position of the right edge of the table.

If ActiveDocument.Tables.Count >= 1 Then
    ActiveDocument.Tables(1).Rows.SetLeftIndent LeftIndent:=18, _
        RulerStyle:=wdAdjustFirstColumn
End If