VBA: Copy As Image from Excel and Paste into Word

社会主义新天地 提交于 2020-06-27 06:12:11

问题


I'm copying a range of cells from Excel as a picture and then pasting into a word document. It pastes at the beginning of the document, how could I set it to paste in a specific area? The area could be denoted by some text that I'd later find/replace.

Thanks!

Range("A1:H5").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture



Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Open("MyFile.docx")

objWord.Visible = True

Set objSelection = objWord.Selection

objSelection.Paste


End Sub

回答1:


I just came accross the same problem and used the following code. I use a bookmark called "here" which is saved in my Word document. HTH, Mitch.

Dim WordApp As Word.Application
Dim WordDoc As Word.Document

Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open("MyFile.docx")

Range("A1:H5").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
WordApp.Visible = True
WordApp.ActiveDocument.Bookmarks("here").Select
Set objSelection = WordApp.Selection
objSelection.Paste


来源:https://stackoverflow.com/questions/43146052/vba-copy-as-image-from-excel-and-paste-into-word

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!