Table of contents
Collapse the table of content
Expand the table of content

Table.Columns Property (Publisher)

office 365 dev account|Last Updated: 8/24/2017
3 Contributors

Returns a Columns collection that represents all the columns of the specified table.


expression. Columns

_expression_A variable that represents a Table object.


This example enters a bold number into each cell in the specified table. This example assumes the specified shape is a table and not another type of shape.

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 = _ 
 .Font.Bold = msoTrue 
 intCount = intCount + 1 
 End With 
 Next celTable 
 Next colTable 

End Sub
© 2018 Microsoft