CellRange Collection






A collection of Cell objects in a table column or row. The CellRange collection represents all the cells in the specified column or row.
Using the CellRange Collection
Use the Cells property to return the CellRange collection. This example merges the cells in first column of the table.
Sub MergeCellsInFirstColumn()
With ActiveDocument.Pages(1).Shapes(1).Table
.Cells(StartRow:=1, StartColumn:=1, _
EndRow:=.Rows.Count, EndColumn:=1).Select
End With
Selection.TableCellRange.Merge
End Sub
Use the Count property to return the number of cells in a row, column, table or selection. This example displays a message with the number of cells the specified table.
Sub NumberOfTableCells()
MsgBox ActiveDocument.Pages(1).Shapes(1).Table _
.Cells.Count
End Sub
Remarks
Although the collection object is named CellRange and is shown in the Object Browser, this keyword is not used in programming the Microsoft Publisher object model. The keyword Cells is used instead.
You cannot programmatically add to or delete individual cells from a Publisher table. Use the AddTable method with the Shapes collection to add a new table to a publication. Use the Add method of the Columns or Rows collections to add a column or row to a table. Use the Delete method of the Columns or Rows collections to delete a column or row from a table.