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 :bow:
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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
:beerchug:
 
Upvote 0

Forum statistics

Threads
1,223,579
Messages
6,173,173
Members
452,505
Latest member
Alice34

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