Columns Property

Microsoft PowerPoint Visual Basic

Returns a Columns collection that represents all the columns in a table. Read-only.

For information about returning a single member of a collection, see Returning an Object from a Collection.

Example

This example displays the shape number, the slide number, and the number of columns in the first table of the active presentation.

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
		

This example tests the selected shape to see if it contains a table. If it does, the code sets the width of column one to 72 points (one inch).

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