ColumnIndex 属性

       

返回包含指定单元格的表格列数。Long 类型,只读。

示例

本示例在新文档中创建表格,选择第一行中的每个单元格,然后返回包含所选单元格的列数。

Dim docNew As Document
Dim tableNew As Table
Dim cellLoop As Cell

Set docNew = Documents.Add
Set tableNew = docNew.Tables.Add(Selection.Range, 3, 3)
For Each cellLoop In tableNew.Rows(1).Cells
    cellLoop.Select
    MsgBox "This is column " & cellLoop.ColumnIndex
Next cellLoop

本示例返回插入点所在的单元格的列数。

Msgbox Selection.Cells(1).ColumnIndex