How can I reliably move down the rows in a Word table?
Here’s the structure of the table. Note that the first and second columns can both have multiple lines and paragraphs.
Rule ID 1
Logic Date must be equal to or greater than 01-Jan-2012
Discrepancy Date is before 01-Jan-2012
message
Test case 1.1 Create form where Date is before 01-Jan-2012
Verify discrepancy message appears.
Print form.
Test case 1.2 Create form where Date is equal to 01-Jan-2012.
Verify no discrepancy message appears.
Print form.
Test case 1.3 Create form where Date is after 01-Jan-2012.
Verify no discrepancy message appears.
Print form.
I have tried a number of methods to move down the table.
When I tried Selection.MoveDown with unit:=wdLine (below) I ran into problems when column 1 contained a word wrap.
Selection.MoveDown unit:=wdLine, Count:=1, Extend:=wdMove
When I tried Selection.MoveDown with unit:=wdParagraph (below), I ran into problems when column 2 contained multiple paragraphs.
Selection.MoveDown unit:=wdParagraph, Count:=3
unit:=wdRow does not appear to be a valid parameter for Selection.MoveDown.
Selection.Cells(1).RowIndex is a read-only parameter
Does anyone know of a simple method to move down the table one row at a time that would handle both the word wraps in column 1 and the multiple paragraphs in column 2?
Try something like this. It’s a generalized algorithm for looping through each row and column of all the tables in a Word document. Modify as needed (untested code):