Table.Columns 属性 (Publisher)

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

语法

表达式

表达 一个代表 Table 对象的变量。

示例

本示例在指定表格的每个单元格中输入一个粗体编号。 此示例假定指定的形状是表格,而不是其他类型的形状。

Sub CountCellsByColumn() 
 Dim shpTable As Shape 
 Dim colTable As Column 
 Dim celTable As Cell 
 Dim intCount As Integer 
 
 intCount = 1 
 
 Set shpTable = ActiveDocument.Pages(2).Shapes(1) 
 
 'Loops through each column in the table 
 For Each colTable In shpTable.Table.Columns 
 
 'Loops through each cell in the column 
 For Each celTable In colTable.Cells 
 With celTable.Text 
 .Text = intCount 
 .ParagraphFormat.Alignment = _ 
 pbParagraphAlignmentCenter 
 .Font.Bold = msoTrue 
 intCount = intCount + 1 
 End With 
 Next celTable 
 Next colTable 
 
End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。