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)
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

joyrock37

New Member
Joined
Oct 14, 2011
Messages
26
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)
 

Watch MrExcel Video

Forum statistics

Threads
1,123,369
Messages
5,601,223
Members
414,434
Latest member
Riyen

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
Top