改变表格列宽,使之在单元格文本换行方式不变的情况下,适应文本宽度。
expression.AutoFit
expression 必需。该表达式返回一个 Column 或 Columns 对象。
如果表格的宽度已等于从左边界到右边界的距离,则此方法无效。
本示例在新文档中创建一个 3x3 表格,然后调整第一列的宽度,使之与文本的宽度相称。
Dim docNew as Document
Dim tableNew as Table
Set docNew = Documents.Add
Set tableNew = docNew.Tables.Add(Range:=Selection.Range, _
NumRows:=3, NumColumns:=3)
With tableNew
.Cell(1,1).Range.InsertAfter "First cell"
.Columns(1).AutoFit
End With
本示例在新文档中创建一个 3x3 表格,然后调整所有列的宽度,使之与文本的宽度相称。
Dim docNew as Document
Dim tableNew as Table
Set docNew = Documents.Add
Set tableNew = docNew.Tables.Add(Selection.Range, 3, 3)
With tableNew
.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