Share via


Table.Columns Property

PowerPoint Developer Reference

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

Syntax

expression.Columns

expression   A variable that represents a Table object.

Return Value
Columns

Remarks

For information about returning a single member of a collection, see How to: Return Objects from Collections.

Example

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

Visual Basic for Applications
  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).

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

See Also