Columns 属性

       

返回一个 Columns 集合,代表表格中的所有列。只读。

有关返回集合中单个元素的详细信息,请参阅返回集合中的对象

示例

本示例显示活动演示文稿内第一个表格中的形状编号、幻灯片编号以及列数。

Dim ColCount As Integer
Dim sl As Integer
Dim sh As Integer

With ActivePresentation
    For sl = 1 To .Slides.Count
        For sh = 1 To .Slides(sl).Shapes.Count
            If .Slides(sl).Shapes(sh).HasTable Then
                ColCount = .Slides(sl).Shapes(sh) _
                    .Table.Columns.Count
                MsgBox "Shape " & sh & " on slide " & sl & _
                    " contains the first table and has " & _
                    ColCount & " columns."
                Exit Sub
            End If
        Next
    Next
End With

本示例检测选定的形状以查看其是否包含表格。如果包含表格,则此代码将设置第一列的列宽为 72 磅(一英寸)。

With ActiveWindow.Selection.ShapeRange
    If .HasTable = True Then
       .Table.Columns(1).Width = 72
    End If
End With