Vba 向下移动包含多段单元格的Word表格中的行

Vba 向下移动包含多段单元格的Word表格中的行,vba,ms-word,word-2010,Vba,Ms Word,Word 2010,如何可靠地向下移动Word表中的行? 这是桌子的结构。请注意,第一列和第二列都可以有多行和多段 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

如何可靠地向下移动Word表中的行?
这是桌子的结构。请注意,第一列和第二列都可以有多行和多段

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.
我已经尝试了很多方法来移动桌子

当我尝试使用
unit:=wdLine
(以下)进行
Selection.MoveDown
时,当第1列包含换行符时,我遇到了问题

Selection.MoveDown unit:=wdLine, Count:=1, Extend:=wdMove
当我尝试使用
unit:=wdparagration
(以下)进行
Selection.MoveDown
时,当第2列包含多个段落时,我遇到了问题

Selection.MoveDown unit:=wdParagraph, Count:=3 
unit:=wdRow
似乎不是
选择的有效参数。向下移动

Selection.Cells(1).行索引
是只读参数


有没有人知道一种简单的方法,可以一次在表中移动一行,同时处理第1列中的换行和第2列中的多个段落

试试这样的东西。它是一种通用算法,用于循环遍历Word文档中所有表的每一行和每一列。根据需要修改(未测试的代码):

Sub ModifyAllTables()
  Dim oTbl As Table
  Dim oRow As Row
  Dim oRng As Range
  For Each oTbl In ActiveDocument.Tables
    For Each oRow In oTbl.Rows
      ' Select the cell in column 2.
      Set oRng = oRow.Cells(2).Range
      ' and do something with it...
      'e.g. oRng.TypeText "modified"
    Next
  Next
End Sub
Sub NextRow()

    Dim c As Long, r As Long

    With Selection
        'ignore if not in table
        If .Information(wdWithInTable) Then

            c = .Columns(1).Index
            r = .Rows(1).Index

            If .Rows(1).Parent.Rows.Count >= r + 1 Then
                .Rows(1).Parent.Rows(r + 1).Cells(c).Range.Select
            End If
        End If
    End With

End Sub