Export Excel print pages to Word document

lumiere

New Member
Joined
Jan 13, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I have an Excel file that contains only one Worksheet but it split into multiple pages with vertical page breaks (see attached image)

What's the best way to export that worksheet to Word document? So each Excel print page is a page in a Word document.
Is there a VBA script anyone can share?

Thanks in advance



Screenshot 2021-01-14 173102.png
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

lumiere

New Member
Joined
Jan 13, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Bump.

So I guess this consists of two tasks
1. Loop through "Print pages" and establish cell ranges for each page
2. Each page's cell range should then be exported as table on a separate page in word document.

Does this sound like a correct way of approaching this?

I can't seem to find a way to do point 1 on my list. Can't find the way to iterate over print pages and get cell ranges. Is it even possible?
 

Dossfm0q

Banned User
Joined
Mar 9, 2009
Messages
570
Office Version
  1. 2019
Platform
  1. Windows
VBA Code:
Sub Export_Excel_print_pages_to_Word_document()

Dim wrdApp As Object
Dim WrdDoc As Object
Dim Pages As Variant

Set wrdApp = CreateObject("Word.Application")

Path = Environ("USERPROFILE") & "\" & "Desktop\"
WrdPath = Path & "wrd.docx"
With wrdApp
    .Visible = True
    .Activate
     Set WrdDoc = .Documents.Add
   
             With WrdDoc
                Pages = Split(ActiveSheet.PageSetup.PrintArea, ",")
               ' MsgBox " You have " & UBound(Pages) + 1
                For P = LBound(Pages) To UBound(Pages)
                .Content.InsertAfter "Page (" & P + 1 & ")"
                ' Add Spaces
                .Paragraphs.Add
                .Paragraphs.Add

                ' Copy Excel
                Range(Pages(P)).Copy

                  'Paste
                .Paragraphs(.Paragraphs.Count).Range.Paste
               ' Add Spaces
                .Paragraphs.Add
                .Paragraphs.Add
                .Paragraphs.Add
                .Paragraphs.Add
                .Paragraphs.Add
                .Paragraphs.Add
                .Paragraphs.Add
                Next
               
               
            End With 'WrdDoc
           
End With 'wrdApp
Application.CutCopyMode = False

Set wrdApp = WrdDoc
Set wrdApp = Nothing

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,231
Messages
5,600,427
Members
414,384
Latest member
joehalks

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