AutoFit Method Example

This example creates a 3x3 table in a new document and then changes the width of the first column to accommodate the width of the text.

Set newDoc = Documents.Add
Set myTable = newDoc.Tables.Add(Range:=Selection.Range, _
    NumRows:=3, NumColumns:=3)
With myTable
    .Cell(1,1).Range.InsertAfter "First cell"
    .Columns(1).AutoFit
End With

This example creates a 3x3 table in a new document and then changes the width of all the columns to accommodate the width of the text.

Set newDoc = Documents.Add
Set myTable = newDoc.Tables.Add(Selection.Range, 3, 3)
With myTable
    .Cell(1,1).Range.InsertAfter "First cell"
    .Cell(1,2).Range.InsertAfter "This is cell (1,2)"
    .Cell(1,3).Range.InsertAfter "(1,3)"
    .Columns.AutoFit
End With