Pasting an Excel data range to a Word bookmark

L

Legacy 306721

Guest
How does one insert an Excel data range to a Word bookmark? Here is my attempt so far:

Code:
Sub CopyToWord()
  Dim wdApp As Object
  Dim wdDoc As Object
  Dim xlRng As Excel.Range
  Dim file_extension As String
  
  ReDim Tables(1 To 16) As String 'an array of 16 variables
    'ranges of tables 1 through 16. Tables(k) = "Range of Table k"
    Tables(1) = "B3:E15"
    Tables(2) = "B19:E31"
'    Tables(3) = "G19:J31"
'    Tables(4) = "B36:E48"
'    Tables(5) = "G36:J48"
'    Tables(6) = "B52:E64"
'    Tables(7) = "G52:J64"
'    Tables(8) = "B68:E80"
'    Tables(9) = "G68:J80"
'    Tables(10) = "B84:E96"
'    Tables(11) = "G84:J96"
    'Tables 2 worksheet
'    Tables(12) = "B3:Q16"
    'Tables 3 worksheet
'    Tables(13) = "B3:AC16"
'    Tables(14) = "B22:AC35"
    'Tables 4 worksheet
'    Tables(15) = "B2:E74"
'    Tables(16) = "K2:N169"
    
    'Word document to which you want to copy - use the entire file extension
    file_extension = "C:\Users\blah"
    'Open Word
    Set wdApp = CreateObject("Word.Application")
    Set wdDoc = wdApp.documents.Open(file_extension)
    wdApp.Visible = True
    
    Dim xlRng1 As Excel.Range
    Set xlRng1 = Range(Tables(1))
    xlRng1.Copy
    
    wdDoc.Content.PasteExcelTable False, False, True
End Sub

I've tried incorporating bookmarks but have had no luck.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,215,200
Messages
6,123,611
Members
449,109
Latest member
Sebas8956

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