一个 列 的集合 对象,表示表中的列。
备注
使用 区域 、 选定内容 或 表格 对象的 列 属性返回 的列 集合。 下面的示例显示活动文档中第一个表的 列 集合中 列 对象的数目。
MsgBox ActiveDocument.Tables(1).Columns.Count
以下示例创建一张三行六列的表格,并设置每列的底纹格式为递增百分比(越来越深)。
Set myTable = ActiveDocument.Tables.Add(Range:=Selection.Range, _
NumRows:=3, NumColumns:=6)
For Each col In myTable.Columns
col.Shading.Texture = 2 + i
i = i + 1
Next col
使用 添加 若要将列添加到表的方法。 下面的示例在活动文档中的第一个表格添加一列,然后将列宽设置为相等。
If ActiveDocument.Tables.Count >= 1 Then
Set myTable = ActiveDocument.Tables(1)
myTable.Columns.Add BeforeColumn:=myTable.Columns(1)
myTable.Columns.DistributeWidth
End If
使用 列 (索引),其中索引是索引号,返回单个 列 对象。 索引号代表列 (从左到右进行计算) 的列 集合中的位置。 下面的示例选定第一张表格的首列。
ActiveDocument.Tables(1).Columns(1).Select
方法
| 名称 |
|---|
| Add |
| AutoFit |
| 删除 |
| DistributeWidth |
| 项 |
| Select |
| SetWidth |
属性
| 名称 |
|---|
| Application |
| Borders |
| Count |
| Creator |
| 第一 |
| 最后一个 |
| NestingLevel |
| Parent |
| PreferredWidth |
| PreferredWidthType |
| Shading |
| Width |
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。