PDA

View Full Version : Paste range as image in merge



kelseyvdh
09-07-2018, 09:57 AM
Hi everyone,

I'm trying to replace some text in a Word-file with a copy of a range from Excel. I want to paste the range as an image. At this point, it does paste the range as an image, but I can't seem to fix it so it would replace the specific text. My code is as following:

With msWord.Content.Find
Sheets("Offerte").Range("I13:M160").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
.Text = ("<<TABEL>>")
.Replacement.Text = msWord.Selection.Paste
msWord.Selection.TypeParagraph
End With


So to elaborate: the Range I13:M160 of the Sheet "Offerte" has to replace the text "<<Tabel>>" in the Word-document. Everything works, except for the replacement of the text.

Any ideas? Many thanks in advance!

macropod
09-07-2018, 02:40 PM
You can't do it that way - you can only use valid Find/Replace expressions, which .Replacement.Text = msWord.Selection.Paste is not. Copy the Excel range, then use:
.Replacement.Text = "^c"

kelseyvdh
09-08-2018, 01:33 AM
Thank you for your answer, but unfortunately this doesn't work either. With ^c or ^v nothing happens. Even when I put in a timer (Sleep). When a try to send a ^v in a seperated line only the 'v' appears in the document. And it will just appear at the top of the document.

Any ideas?

macropod
09-08-2018, 05:30 AM
Perhaps you need to study a bit more on: a) what valid Find and Replace expressions can be (There was a reason I said to use ^c and I very much doubt you really want to use ^v); and b) what you actually need to add to your code to make a Find/Replace execute...