Table Object

Microsoft PowerPoint Visual Basic

Multiple objectsTable
Multiple objects

Represents a table shape on a slide. The Table object is a member of the Shapes collection. The Table object contains the Columns collection and the Rows collection.

Using the Table Object

Use Shapes(index), where index is a number, to return a shape containing a table. Use the HasTable property to see if a shape contains a table. This example walks through the shapes on slide one, checks to see if each shape has a table, and then sets the mouse click action for each table shape to advance to the next slide.

With ActivePresentation.Slides(2).Shapes
    For i = 1 To .Count
        If .Item(i).HasTable Then
            .Item(i).ActionSettings(ppMouseClick) _
                .Action = ppActionNextSlide
        End If
    Next
End With
		

Use the Cell method of the Table object to access the contents of each cell. This example inserts the text "Cell 1" in the first cell of the table in shape five on slide three.

ActivePresentation.Slides(3).Shapes(5).Table _
    .Cell(1, 1).Shape.TextFrame.TextRange _
    .Text = "Cell 1"
		

Use the AddTable method to add a table to a slide. This example adds a 3x3 table on slide two in the active presentation.

ActivePresentation.Slides(2).Shapes.AddTable(3, 3)