VBA - How to open a sheet range in MS Word, complete with all formatting from the Excel sheet

Jasesair

Active Member
Joined
Apr 8, 2015
Messages
282
Office Version
  1. 2016
I have a sheet range (A1:I18) that is formatted the way I want with picture, different row and column widths, cell highlighting, cell borders, different font sizes etc. I'd like assign macro to a button that then sends the user to MS Word, opening up the Excel cells as converted in an MS Word file. Any help to do this would be fantastic!

I'm very, very green to VBA and have no idea even how to record macros etc.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
select desire range in excel
copy that
right click in word file
and select paste option
"link & keep source formating"
 
Upvote 0
select desire range in excel
copy that
right click in word file
and select paste option
"link & keep source formating"
That's exactly what I want to do but I need all that to happen with one button click from Excel. I need that button click to open a new Word file and insert the range I need, with the source formatting.
 
Upvote 0
VBA Code:
Private Sub CommandButton1_Click()
Set wordapp = CreateObject("word.application")
wordapp.documents.Open "e:\test.docx" 'word file address
wordapp.Visible = True

 Range("A1:F9").Select 'range which you want to transfer to word file
     Selection.Copy
     Application.CutCopyMode = False
End Sub
 
Upvote 0
and write this code to word file


Private Sub Document_Open()
Selection.PasteExcelTable True, False, False
End Sub
 
Upvote 0
Simpler, more reliable, and more straightforward:
VBA Code:
Private Sub CommandButton1_Click()
Dim wdApp As Object, wdDoc As Object
Range("A1:F9").Copy
Set wdApp = CreateObject("Word.Application")
With wdApp
  .Visible = True
  Set wdDoc = .Documents.Add
  wdDoc.PasteExcelTable True, False, False
End With
Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,580
Members
448,972
Latest member
Shantanu2024

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