Excel to Word page break

joyrock37

New Member
Joined
Oct 14, 2011
Messages
26
Hi All,
yesterday I've been helped beautifully and now I'm stuck again...:confused:

My code now copies ranges from Excel to Word nicely, but I need to add page breaks. If I just run the code
wdDoc.Range(wdDoc.Content.End - 1).InsertBreak Type:=7
it works, but when added to the existing code below, it doesn't.

Code:
Sub ExcelToWord()

Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Add
wdApp.Visible = True

'Page 1 (Picture)
ThisWorkbook.Sheets("Graphs").Range("A80:P116").Copy
wdApp.Selection.PasteSpecial Link:=False, DataType:=9, _
        Placement:=wdInLine, DisplayAsIcon:=False
wdApp.Selection.Characters.Last.Select
wdDoc.Range(wdDoc.Content.End - 1).InsertBreak Type:=7
    
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub


Thank you for helping out (y)
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hello All,
I found another snippet of code that works!

Instead of
wdDoc.Range(wdDoc.Content.End - 1).InsertBreak Type:=7
I am using
wdApp.Selection.InsertBreak Type:=7
(y)
 
Upvote 0

Forum statistics

Threads
1,215,832
Messages
6,127,150
Members
449,366
Latest member
reidel

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