I have hundreds of excel sheets that need to be pasted into Word with a pagebreak between them. I have tried SEVERAL different codes, and I only either get 1 table pasted, or 40 pagebreaks with no tables at all. How do I paste a table, add a pagebreak after the table, and then add another table after the pagebreak? Any ideas?
VBA Code:
For i = 0 To c - 1
Set tblRange = ThisWorkbook.Worksheets(tblArray(0, i)).Range(Cells(2, 2).Address(), Cells(tblArray(1, i), 13).Address()) 'tblArray(1,i) calls lastrow value to properly size the range for nonuniform sheets
tblRange.Copy
'''''WordDoc.Bookmarks(bkmkArray(i)).Range.PasteExcelTable I tried this line instead of the one below, using an array to name bookmarks
WordDoc.Paragraph(i).PasteExcelTable _
LinkedtoExcel:=False, _
WordFormatting:=False, _
RTF:=False
Set WordTable = WordDoc.Tables(i)
With WordTable
.AutoFitBehavior wdAutoFitContent
.Borders.OutsideLineStyle = wdLineStyleSingle
.Borders.OutsideLineWidth = wdLineWidth225pt
.Range.ParagraphFormat.LineSpacing = 12
.Range.ParagraphFormat.SpaceAfter = 0
End With
With WordApp.Selection 'Selects the table range
.InsertBreak (7)
'.InsertBreak Type:=wdPageBreak 'adds a pagebreak after the table
End With
Next i
WordApp.Visible = True
WordApp.Activate