SetWidth Method Example

This example creates a table in a new document and sets the width of the first cell in the second row to 1.5 inches. The example preserves the widths of the other cells in the table.

Set newDoc = Documents.Add
Set myTable = _
    newDoc.Tables.Add(Range:=Selection.Range, NumRows:=3, _
    NumColumns:=3)
myTable.Cell(2,1).SetWidth _
    ColumnWidth:=InchesToPoints(1.5), _
    RulerStyle:=wdAdjustNone

This example sets the width of the cell that contains the insertion point to 36 points. The example also narrows the first column to preserve the position of the right edge of the table.

If Selection.Information(wdWithInTable) = True Then
    Selection.Cells(1).SetWidth ColumnWidth:=36, _
        RulerStyle:=wdAdjustFirstColumn
Else
    MsgBox "The insertion point is not in a table."
End If