View Single Post
 
Old 10-03-2019, 05:15 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If your tables have at least one empty paragraph after each one (and two at the end of the doc) then the following code will work
Code:
Sub Temp3()
  Dim i As Integer, iCount As Integer, aRng As Range, aTblRng As Range, j As Integer
  iCount = InputBox("How many duplicates?", , "1")
  For i = ActiveDocument.Tables.Count To 1 Step -1
    Set aRng = ActiveDocument.Tables(i).Range.Paragraphs.First.Previous.Range
    aRng.MoveEnd Unit:=wdCharacter, Count:=-1
    If aRng.ParagraphFormat.OutlineLevel < wdOutlineLevel3 Then
      Set aTblRng = ActiveDocument.Tables(i).Range
      aTblRng.End = aTblRng.Paragraphs.Last.Next.Range.End
      Set aRng = aTblRng.Duplicate
      For j = iCount To 1 Step -1
        aRng.Collapse wdCollapseEnd
        aRng.FormattedText = aTblRng.FormattedText
      Next j
    End If
  Next i
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote