Sub SaveXlRangeToWordFile2()
Dim WidthAvail As Double, ARR() As Variant
Dim WdDoc As Object, WdApp As Object, Cnt As Integer, Cnter As Integer
Dim Prng1 As Range, Prng2 As Range, Prng3 As Range
'set page print ranges
With Sheets("sheet1")
Set Prng1 = .Range(.Cells(1, "A"), .Cells(47, "I"))
Set Prng2 = .Range(.Cells(1, "J"), .Cells(47, "R"))
Set Prng3 = .Range(.Cells(1, "S"), .Cells(47, "AA"))
End With
'make array of print ranges
ARR = Array(Prng1, Prng2, Prng3)
'open Word application
On Error Resume Next
Set WdApp = GetObject(, "word.application")
If Err.Number <> 0 Then
On Error GoTo 0
Set WdApp = CreateObject("Word.Application")
End If
On Error GoTo erfix
'open doc **********change file path to suit
Set WdDoc = WdApp.Documents.Open(Filename:="C:\yourfoldername\bart.docx")
'clear doc
With WdApp.ActiveDocument
.Range(0, .Characters.Count).Delete
End With
'determine width
With WdApp.ActiveDocument.PageSetup
WidthAvail = .PageWidth - .LeftMargin - .RightMargin - .Gutter
End With
'loop print ranges
For Cnter = LBound(ARR) To UBound(ARR)
Cnt = Cnt + 1
ARR(Cnter).Copy
WdDoc.Paragraphs(WdDoc.Paragraphs.Count).Range.PasteSpecial DataType:=3 '9 '4
'size range pic to sheet
With WdDoc.Shapes(Cnt)
.LockAspectRatio = msoFalse
.Width = WidthAvail
End With
Application.CutCopyMode = False
OpenClipboard (0&)
EmptyClipboard
CloseClipboard
'paste to seperate page
WdDoc.Paragraphs(WdDoc.Paragraphs.Count).Range.InsertParagraphAfter
With WdDoc.Paragraphs(WdDoc.Paragraphs.Count).Range
.InsertParagraphAfter
.Collapse Direction:=0 'wdCollapseEnd
.InsertBreak Type:=7 'wdPageBreak
End With
Next Cnter
'clean up
WdApp.ActiveDocument.Close SaveChanges:=True
Set WdDoc = Nothing
WdApp.Quit
Set WdApp = Nothing
Exit Sub
erfix:
On Error GoTo 0
MsgBox "Save SaveXlRangeToWordFile error"
WdApp.ActiveDocument.Close SaveChanges:=False
Set WdDoc = Nothing
WdApp.Quit
Set WdApp = Nothing
Application.CutCopyMode = False
End Sub