I have a table with cells merged together.some cells are having row spans as
well as col spans
now i want to navigate through the table and find out value in each cell of
the table.I am doing this by two for loops first one increments row number
and second one increments column number.This code is working fine if any of
the cells have not merged with other cell.
If i merge some of the cells then this code gives error saying can not
access individual rows since there are vertically merged cells.
Do you have solution for this problem?
Jonathan West - 25 Nov 2004 12:18 GMT
>I have a table with cells merged together.some cells are having row spans
>as
[quoted text clipped - 11 lines]
>
> Do you have solution for this problem?
This code example will show you how to cope
Sub SetCellNumbers()
Dim oCell As Cell
For Each oCell In ActiveDocument.Tables(1).Range.Cells
oCell.Range.InsertAfter oCell.RowIndex & " " & oCell.ColumnIndex
Next oCell
End Sub

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Helmut Weber - 25 Nov 2004 13:09 GMT
Hi,
you can still loop through all cells like this,
Dim oCll As Cell
With ActiveDocument.Tables(1).Range
For Each oCll In .Cells
oCll.Select
Next
End With
or use for i = 1 to ActiveDocument.Tables(1).Range.Cells.Count
You also can access r (row) and c (col) of the given cell:
r = oCll.RowIndex
c = oCll.ColumnIndex
If you have merged cells (1,2) and (2,2) vertically,
then cell(2,2) has vanished. Though, with horizontally merged cells,
this method doesn't work, and I wonder, if there is a solution at all.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Jezebel - 28 Dec 2004 05:27 GMT
And for a third method of iterating all the cells in a table --
Dim pCell as Word.Cell
Set pCell = Selection.Tables(1).Cell(1,1) 'This cell always
exists, whatever merging or splitting you might have done
Do
.... work with pCell
set pCell = pCell.Next
Loop until pCell is nothing
> I have a table with cells merged together.some cells are having row spans as
> well as col spans
[quoted text clipped - 8 lines]
>
> Do you have solution for this problem?