vba from excel to word

mirinjawbro

New Member
Joined
Sep 28, 2016
Messages
30
Hello everyone

What's the simplest way to

Copy a1 to k40 in an excel sheet

Open a new word document. Paste. Fit to one page with narrow margins

Thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Code:
Sub F()


    Dim wdApp As Object
    Dim doc As Object

    Set wdApp = CreateObject("Word.Application")
    wdApp.Visible = True
    Set doc = wdApp.Documents.Add()
   
    Range("A1:K40").Copy
    doc.Range.PasteExcelTable False, False, False

End Sub
 
Upvote 0
Thanks it worked. However it's pasting different to when I just copy and paste. Its taking up 2 pages?

How can I then edit that to have narrow margins ?

Thanks again
 
Upvote 0
You will have to choose the appropriate paste format and/or add code to reformat the table after pasting it. Copying an Excel range, then starting Word's macro recorder before pasting should generate some code you can use as a starting point.
 
Upvote 0

Forum statistics

Threads
1,223,803
Messages
6,174,684
Members
452,577
Latest member
Filipzgela

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