The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
This documentation is archived and is not being maintained.
Error Accessing a Table Row or Column
Word Developer Reference
When you try to access an individual row or column in a drawn table, a run-time error may occur if the table is not uniform. For example, the following instruction posts an error if the first table in the active document does not have the same number of rows in each column.
ActiveDocument.Tables(1).Rows(1).Borders.Enable = False
You can avoid this error by first selecting the cells in a column or row using the SelectColumn
method or the SelectRow
method. After the selection is made, use the Cells
property with the Selection
object. The following example selects the first row in the first document table. The Cells property is used to access the selected cells (all the cells in the first row) so that borders can be removed.
.Cells.Borders.Enable = False
The following example selects the first column in the first document table. The For Each...Next loop is used to add text to each cell in the selection (all the cells in the first column).
Dim intCell As Integer
Dim oCell As Cell
intCell = 1
For Each oCell In Selection.Cells
oCell.Range.Text = "Cell " & intCell
intCell = intCell + 1