复制Excel单元格并粘贴到Word中作为图像
问题描述:
我正在尝试捕获一系列单元格的图像。该图像可以保存或粘贴到相同的excel文档中,粘贴到单词文档等中。我只需要从一组单元格生成图像。
I'm trying to capture an image of a range of cells. This image can either be saved, or pasted into the same excel document, pasted into a word document, etc. I just need to generate images from a groups of cells.
我以为我已经通过复制和粘贴到这个文字来解决了这个问题:
I thought I had figured it out by copying and pasting into word with this:
Dim objWord, objDoc As Object
ActiveWindow.View = xlNormalView
Range("A1:B45").Select
Selection.Copy
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
objWord.Visible = True
objWord.Selection.PasteSpecial Link:=False, DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine, DisplayAsIcon:=False
objWord.Selection.TypeParagraph
当我运行它,它似乎工作。但是用粘贴的对象实际上是一个像元文件一样的电子表格对象。 (所以它将数据作为一个嵌入式excel表)。
When I run this, it seems to work. But the object that's pasted in word is actually a spreadsheet object that acts like a metafile. (So it's bringing the data along with it as an embedded excel sheet).
任何建议?
答
这似乎起作用:
Sub luxation()
Dim objWord, objDoc As Object
ActiveWindow.View = xlNormalView
Range("A1:B45").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
objWord.Visible = True
objWord.Selection.Paste
objWord.Selection.TypeParagraph
End Sub