Copying an excel File and putting it into Word

coleyoder

New Member
Joined
Nov 29, 2018
Messages
9
I am currently trying to copy an excel worksheet and paste it into a word document and turn it horizontally.

I know about to create a text box and turning it to be horizontal then copying special the excel sheet in.

But when doing that the excel spreadsheet is too big to fit on the whole page and it won let me shrink it to fit on the page and that is the main thing I need to do.

Any advice would be great thank you!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
You could, for example, use a landscape page layout. Try something based on:
Code:
Sub Excel_to_Word()
'Note: This code requires a reference to the Word Object Library to be set.
Dim wdApp As New Word.Application, wdDoc As Word.Document
Dim xlRng As Excel.Range, r As Long, c As Long, FlNm As String
With ActiveWorkbook
  FlNm = Split(.FullName, ".xls")(0) & ".docx"
  With .ActiveSheet
    With .UsedRange.Cells.SpecialCells(xlCellTypeLastCell)
      r = .Row
      c = .Column
    End With
    Set xlRng = .Range(.Cells(1, 1), .Cells(r, c))
  End With
End With
With wdApp
  .Visible = False
  Set wdDoc = .Documents.Add
  With wdDoc
    .PageSetup.Orientation = wdOrientLandscape
    xlRng.Copy
    .Range.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False, RTF:=False
    .SaveAs Filename:=FlNm, FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
    .Close False
  End With
  .Quit
End With
Application.CutCopyMode = False
Set xlRng = Nothing: Set wdDoc = Nothing: Set wdApp = Nothing
End Sub
If you need to have the rest of the document in portrait format, you'll need to insert 'Next Page' Section breaks before and/or after wherever you want to insert the table, specifying the location of both the Section break(s) and the destination to paste to; the above code doesn't do any of that.

Note: For testing, you might want to change '.Visible = False' to '.Visible = True'.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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