VBA:复制单元格,粘贴为图片,然后另存为图片? [英] VBA: Copy cells, paste as a picture, then save as a picture?
本文介绍了VBA:复制单元格,粘贴为图片,然后另存为图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
Range("A1:M28").CopyPicture Appearance:=xlScreen, Format:=xlPicture
Sheets.Add.Name = "Without Formatting"
Worksheets("Without Formatting").Paste _
Destination:=Worksheets("Without Formatting").Range("A1:M28")
复制一些单元格,然后将其作为图片粘贴到另一个工作表中,有没有一种将图片(最好是jpeg)保存到特定位置的方法,以便我可以在电子邮件中使用图片?
That copies some cells then pastes them as a picture in another worksheet, is there a way of saving the picture (preferably as a jpeg) into a specific location so that I can then use the picture in an email?
推荐答案
我以前使用过以下内容。它将单元格复制为图像,创建新图表,将图像粘贴到图表中,将图表导出为图像,然后删除图表。
I have used the following in the past. It copies the cells as an image, creates a new chart, paste the image into the chart, export the chart as an image then deletes the chart.
Range("A1:M28").CopyPicture Appearance:=xlScreen, Format:=xlPicture
Set cht = ActiveSheet.ChartObjects.Add(0, 0, Rng.Width + 0.01, Rng.Height + 0.01)
cht.Name = "tempchart"
cht.Chart.Paste
ActiveChart.Shapes.Range(Array("chart")).Select
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Line.Visible = msoFalse
ActiveSheet.ChartObjects("tempchart").Activate
ActiveSheet.Shapes("tempchart").Fill.Visible = msoFalse
ActiveSheet.Shapes("tempchart").Line.Visible = msoFalse
cht.Chart.Export strPath & "c:\filepath\imagename.jpg"
ActiveSheet.ChartObjects.Delete
希望这将有助于,
这篇关于VBA:复制单元格,粘贴为图片,然后另存为图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文