Excel宏拍摄特定单元格的屏幕截图并另存为图像文件 [英] Excel macro to take a screenshot of specific cells and save as image file

查看:123
本文介绍了Excel宏拍摄特定单元格的屏幕截图并另存为图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个Excel文件,我需要一个宏,该宏仅截取当前工作表的G3至J14单元格的屏幕截图,并将其另存为图像文件(任何常用格式都可以)到包含Excel文件的文件夹中文件名与单元格B3的内容匹配.

I am working on an Excel file and I need a macro that takes a screenshot of just cells G3 to J14 of the current sheet and saves it as an image file (any common format will do) to the folder containing the Excel file with a file name matching the contents of cell B3.

推荐答案

这似乎有效:

Sub Macro1()
    myFileName = "chrt.png"
    Range("G3:J14").Select
    Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

    Charts.Add
    ActiveChart.Paste
    ActiveChart.Export Filename:=ThisWorkbook.Path & "\" & myFileName, Filtername:="PNG"
End Sub

但是您可能需要调整大小或编辑结果图片以满足您的需求.完成后,您可能还想删除图表.

But you may need to resize or edit the resulting picture to meet your needs. You also may want to delete the Chart when you are done.

这篇关于Excel宏拍摄特定单元格的屏幕截图并另存为图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆