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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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