Copy from Excel to Word Doc as Multiple Images

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
I have a spread sheet that consolidates multiple worksheets into one. Then, the user sets the page breaks. Next, the user can hit a "PDF" button and it will export to pdf. It looks great - exactly as it does in excel. But, I cant quite seem to get the Word export to work.

When the "Word" button is clicked, it opens new word doc, pastes the print area from excel, and autofits to fit the window. Unfortunately, its not clean looking when I do this.

I would like to copy the print area and paste each page as a separate image one after the other
Any thoughts?

Current Code:
Code:
Sub printer()
    Const strRangeToCopy As String = "print_area"
    Dim appWord As Object
    Range(strRangeToCopy).Copy
    'Copy Excel Table Range
 
    On Error Resume Next
    Set appWord = GetObject(, "Word.Application")
    On Error GoTo 0
    If appWord Is Nothing Then Set appWord = CreateObject("Word.Application")
    With appWord
        .Documents.Add
        .Selection.Paste
        .Visible = True
    End With
    ActiveDocument.Tables(1).AutoFitBehavior _
    wdAutoFitWindow
     
End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
If I use the code below, I can get it to paste as an image... but what I really need is to copy/paste the area as multiple images along the page breaks defined in excel.

Code:
Sub printer()
    Const strRangeToCopy As String = "print_area"
    Dim appWord As Object
    Range(strRangeToCopy).Copy
    'Copy Excel Table Range
 
    On Error Resume Next
    Set appWord = GetObject(, "Word.Application")
    On Error GoTo 0
    If appWord Is Nothing Then Set appWord = CreateObject("Word.Application")
    With appWord
        .Documents.Add
        .Selection.PasteAndFormat wdChartPicture
        .Visible = True
    End With
     
End Sub
 
Upvote 0
An object pasted into a Word document cannot span a page break. Consequently, if you need an image of each Excel page, each of those pages would have to be pasted into Word as a separate image.

That said, if all you're doing is producing PDFs, I really can't see the point of involving Word when you can do the job directly from Excel.
 
Upvote 0
The goal is to be able to export the deliverable into various formats for inclusion into proposals. Sometimes we are able to submit this artifact as a separate PDF, but other times we are required to include the artifact within our word document.

Is there an easy way to assign each page as a separate range? And cycle through all of the ranges to copy/paste them into word?
 
Upvote 0
In that case, when you need PDFs, create them directly from Excel; when you want Word documents, either copy & paste the data to Word as a Word table (which can span multiple pages) or loop through the 'pages' in Excel (which means the macro would have to be able to work out what the range to copy is, both for the individual page and overall) and copy & paste each page as an image into Word.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,934
Members
449,094
Latest member
teemeren

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