Pasting several tables in Word with pagebreak after each one

teresaa

New Member
Joined
Jul 30, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
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
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,215,819
Messages
6,127,047
Members
449,356
Latest member
tstapleton67

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top