感谢KONGGS兄的代码。
去年我也曾做过一个(比较简陋),正如孔兄所言,并非真正解决之道。一并拿出来,希望对大家有所帮助。
Sub Example() Dim myTable As Table, oRow As Row, myRow As Row Dim KeyText As String KeyText = "接续上表" Application.ScreenUpdating = False Set myTable = Selection.Tables(1) For Each oRow In myTable.Rows If VBA.InStr(oRow.Range, KeyText) = 1 Then oRow.Delete Next Set myTable = Selection.Tables(1) For Each oRow In myTable.Rows If oRow.IsFirst = True Then GoTo GN If oRow.Range.Information(wdActiveEndPageNumber) <> oRow.Previous.Range.Information(wdActiveEndPageNumber) Then Set myRow = myTable.Rows.Add(oRow) With myRow .Cells.Merge .Range.Text = KeyText .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone .Borders(wdBorderTop).LineStyle = wdLineStyleNone End With End If GN: Next Application.ScreenUpdating = True End Sub |