2017-03-31 432 views
0

我從Excel複製一系列單元格作爲圖片,然後粘貼到單詞文檔中。它粘貼在文檔的開頭,我怎樣才能將它粘貼到特定區域?該區域可以用一些文字表示,我稍後會找到/替換。VBA:從Excel複製爲圖像並粘貼到Word中

謝謝!

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 
+0

對此的任何建議嗎? – user7459948

回答

0

我剛剛遇到同樣的問題,並使用下面的代碼。我使用名爲「here」的書籤保存在我的Word文檔中。 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