Saturday, November 24, 2012

How to make image out of Excel chart in VBA?

After figuring out the code to generate image out of ranges (click here to see) I did some research to figure out how to make image out of a chart. It turned out to be pretty much similar.


Sub Chart_Image()

'DEFINE THE CHART VARIABLE
Dim chart As chart

'SELECTING THE ACTIVE CHART
Set chart = ActiveChart

'COPYING THE RANGE TO AS BITMAP INMEMORY
chart.CopyPicture xlScreen, xlBitmap

'PASTING THE INMEMORY IMAGE TO THE WORKSHEET
ActiveSheet.Paste

End Sub



No comments:

Post a Comment