Moving down a row in a Word table containing multi-paragraph cells

我怕爱的太早我们不能终老 提交于 2019-12-02 02:18:52
Robert Harvey

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):

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!