单元格 的集合 表列、 表行、 选定内容或范围中的对象。
备注
使用 Cells 属性来返回该 单元格 的集合。 下面的示例设置为 30 磅宽的活动文档中表格 1 的第一行中的单元格的格式。
ActiveDocument.Tables(1).Rows(1).Cells.Width = 30
以下示例返回当前行的单元格数。
num = Selection.Rows(1).Cells.Count
使用 添加 方法将 单元格 对象添加到 单元格 集合。 您还可以使用 InsertCells 要插入新单元格的 所选内容 对象的方法。 下面的示例在 myTable 添加之前的第一个单元格的单元格。
Set myTable = ActiveDocument.Tables(1)
myTable.Range.Cells.Add BeforeCell:=myTable.Cell(1, 1)
使用 Cell (行、列) (其中 row 是行号,列是列号)或 单元格 (索引) (其中 index 是索引号)返回 Cell 对象。 下面的示例给表格 1 的第一行中的第二个单元格加底纹。
Set myCell = ActiveDocument.Tables(1).Cell(Row:=1, Column:=2)
myCell.Shading.Texture = wdTexture20Percent
以下示例对第一行的第一个单元格应用底纹。
ActiveDocument.Tables(1).Rows(1).Cells(1).Shading _
.Texture = wdTexture20Percent
说明
使用 Add 方法向 行 或 列 的集合中添加行或列的单元格。 下面的示例向活动文档中第一个表格添加一列,第一列中插入编号。
Set myTable = ActiveDocument.Tables(1)
Set aColumn = myTable.Columns.Add(BeforeColumn:=myTable.Columns(1))
For Each aCell In aColumn.Cells
aCell.Range.Delete
aCell.Range.InsertAfter num + 1
num = num + 1
Next aCell
方法
| 名称 |
|---|
| Add |
| AutoFit |
| 删除 |
| DistributeHeight |
| DistributeWidth |
| 项 |
| Merge |
| SetHeight |
| SetWidth |
| Split |
属性
| 名称 |
|---|
| Application |
| Borders |
| Count |
| Creator |
| Height |
| HeightRule |
| NestingLevel |
| Parent |
| PreferredWidth |
| PreferredWidthType |
| Shading |
| VerticalAlignment |
| Width |
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。