问题
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