會傳回 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 支援與意見反應。