使用 VBA 代码,如何在 Excel 2003 中将 Excel 工作表导出为图像? [英] Using VBA code, how to export Excel worksheets as image in Excel 2003?

查看:31
本文介绍了使用 VBA 代码,如何在 Excel 2003 中将 Excel 工作表导出为图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请建议以 .jpeg 或 .png 或 .gif 格式将 Excel 工作表中的数据范围导出为图像的更好方法.

Please suggest the better way of exporting range of data from excel worksheets as image either in .jpeg or .png or in .gif.

推荐答案

你想试试我多年前在互联网上找到并使用的以下代码吗.

do you want to try the below code I found on the internet somewhere many moons ago and used.

它使用Chart对象的Export函数和Range对象的CopyPicture方法.

It uses the Export function of the Chart object along with the CopyPicture method of the Range object.

参考资料:

  • MSDN - Export method as it applies to the Chart object. to save the clipboard as an Image
  • MSDN - CopyPicture method as it applies to the Range object to copy the range as a picture

dim sSheetName as string
dim oRangeToCopy as range
Dim oCht As Chart

sSheetName ="Sheet1" ' worksheet to work on
set  oRangeToCopy =Range("B2:H8") ' range to be copied

Worksheets(sSheetName).Range(oRangeToCopy).CopyPicture xlScreen, xlBitmap
set oCht =charts.add

with oCht
    .paste
    .Export FileName:="C:SavedRange.jpg", Filtername:="JPG"
end with

这篇关于使用 VBA 代码,如何在 Excel 2003 中将 Excel 工作表导出为图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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