View Single Post
 
Old 07-07-2022, 07:17 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
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

You need to be more specific about where the breaks are and where the tables need to be placed in Word.

If you are putting the content into a blank Word document and the tables are just in order and defined by the empty first cell in a row then you could do a single paste and then split the table up.
Code:
Sub Demo()
  Dim wdApp As New Word.Application, wdDoc As Word.Document, wdTable As Word.Table
  Dim aRng As Range, i As Integer
  Set aRng = ActiveSheet.UsedRange
  aRng.Copy
  With wdApp
    .Visible = True
    Set wdDoc = .Documents.Add
    wdDoc.Range.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False, RTF:=True
    Set wdTable = wdDoc.Tables(1)
    For i = wdTable.Rows.Count To 1 Step -1
      If Len(wdTable.Rows(i).Range.Cells(1).Range.Text) < 3 Then
        wdTable.Rows(i).ConvertToText Separator:=vbCr
      End If
    Next i
  End With
  Set wdDoc = Nothing: Set wdApp = Nothing
  Application.CutCopyMode = False
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote