VBA:将excel区域导出为图像并另存为文件。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VBA:将excel区域导出为图像并另存为文件。相关的知识,希望对你有一定的参考价值。
PROBLEM:How to save Excel range into image file. VBA macro in Excel 2007.
SOLUTION:
Create an empty chart, paste range image into chart area, and Export as image file.
Modify code to suite to your needs.
''' Set Range you want to export to file Dim rgExp As Range: Set rgExp = Range("B5:H14") ''' Copy range as picture onto Clipboard rgExp.CopyPicture Appearance:=xlScreen, Format:=xlBitmap ''' Create an empty chart with exact size of range copied With ActiveSheet.ChartObjects.Add(Left:=rgExp.Left, Top:=rgExp.Top, _ Width:=rgExp.Width, Height:=rgExp.Height) .Name = "ChartVolumeMetricsDevEXPORT" .Activate End With ''' Paste into chart area, export to file, delete chart. ActiveChart.Paste ActiveSheet.ChartObjects("ChartVolumeMetricsDevEXPORT").Chart.Export "C: estmeExportChart.jpg" ActiveSheet.ChartObjects("ChartVolumeMetricsDevEXPORT").Delete
以上是关于VBA:将excel区域导出为图像并另存为文件。的主要内容,如果未能解决你的问题,请参考以下文章