|
- ' 使用类似方法定位第二个表格中的单元格(假设内容为Title11)
- Sub Demo()
- Dim t As Table, c As Cell, Col1 As Range
- Dim txt As String, bFound As Boolean
- Set t = ActiveDocument.Tables(1)
- For Each c In t.Range.Cells
- If c.ColumnIndex = 1 Then
- txt = c.Range.Text
- txt = Left(txt, Len(txt) - 2)
- If txt = "Title11" Then
- c.Range.Select
- Selection.MoveDown Unit:=wdLine, Count:=1
- Selection.Start = c.Range.Start
- Selection.Copy
- bFound = True
- Exit For
- End If
- End If
- Next
- If bFound Then
- With ActiveDocument.Tables(2)
- For Each c In .Range.Cells
- If c.ColumnIndex = 1 Then
- txt = c.Range.Text
- txt = Left(txt, Len(txt) - 2)
- If txt = "Title11" Then
- c.Range.Select
- c.Delete ShiftCells:=wdDeleteCellsEntireRow
- Selection.PasteAndFormat wdFormatOriginalFormatting
- Exit For
- End If
- End If
- Next
- End With
- End If
- End Sub
复制代码 |
|