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.
''' Set Range you want to export to fileDim rgExp As Range: Set rgExp = Range("B5:H14")''' Copy range as picture onto ClipboardrgExp.CopyPicture Appearance:=xlScreen, Format:=xlBitmap''' Create an empty chart with exact size of range copiedWith ActiveSheet.ChartObjects.Add(Left:=rgExp.Left, Top:=rgExp.Top, _Width:=rgExp.Width, Height:=rgExp.Height).Name = "ChartVolumeMetricsDevEXPORT".ActivateEnd With''' Paste into chart area, export to file, delete chart.ActiveChart.PasteActiveSheet.ChartObjects("ChartVolumeMetricsDevEXPORT").Chart.Export "C:\testmeExportChart.jpg"ActiveSheet.ChartObjects("ChartVolumeMetricsDevEXPORT").Delete
Modify code to suite to your needs.
No comments:
Post a Comment