Columns Object

PowerPoint Developer Reference

A collection of Column objects that represent the columns in a table.

Example

Use the Columns property to return the Columns collection. This example finds the first table in the active presentation, counts the number of Column objects in the Columns collection, and displays information to the user.

Visual Basic for Applications
  Dim ColCount, sl, 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

Use the Add method to add a column to a table. This example creates a column in an existing table and sets the width of the new column to 72 points (one inch).

Visual Basic for Applications
  With ActivePresentation.Slides(2).Shapes(5).Table
    .Columns.Add.Width = 72
End With

Use Columns(index) to return a single Column object. Index represents the position of the column in the Columns collection (usually counting from left to right; although the TableDirection property can reverse this). This example selects the first column of the table in shape five on the second slide.

Visual Basic for Applications
  ActivePresentation.Slides(2).Shapes(5).Table.Columns(1).Select

See Also