Copy two tables from Excel and insert in Word

perola.rike

Board Regular
Joined
Nov 10, 2011
Messages
151
I have a WB that exports reports to Word. In this macro, I have a code that finds a specific text (insert table 1 here) in the Word document, and pastes Table 1 at this place. Code 1 inserted below, this is an excerpt from the larger "export from excel to word" code.

However, I would like to copy and paste another Table from another sheet with another range into the same Word document, but I fail to write this code. I tried to duplicate/clone the code below, changed the ranges and text, but it won't work. Code 2 inserted below.

Any tips how to make this work?


Code1

'Paste tables into Word
Set wdRng = wdDoc.Range
With wdRng

'Insert table 1
.Find.ClearFormatting
.Find.Execute FindText:="INSERT TABLE 1 HERE", Forward:=True, Format:=False, Wrap:=wdFindStop
If .Find.Found Then
Call Sheets("Samleprofil").Range("H4:AY28").CopyPicture(xlScreen, xlPicture)
.Paste
End If
Application.CutCopyMode = False
End With

'Insert Table 2
CODE????


Code 2 (this fails)

Set wdRng = wdDoc.Range
With wdRng
.Find.ClearFormatting
.Find.Execute FindText:="ZZZZZ", Forward:=True, Format:=False, Wrap:=wdFindStop
If .Find.Found Then
Call Sheets("WAIS IV Indekser").Range("L1:s16").CopyPicture(xlScreen, xlPicture)
.Paste
End If
Application.CutCopyMode = False
End With
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Watch MrExcel Video

Forum statistics

Threads
1,129,493
Messages
5,636,641
Members
416,932
Latest member
mm07

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