Saturday, November 24, 2012

How to make image out of Excel range in VBA?

One of my colleague one day came to me to figure out how can someone generate an image out of an Excel range in VBA as he found it difficult. I did little research around it and came out with following. 


Sub Range_Image()

'DEFINE THE RANGE VARIABLE
Dim range As range

'SELECTING A PREDEFINED RANGE FROM ACTIVE WORKSHEET
Set range = ActiveSheet.range("A1:C3")

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

'PASTING THE INMEMORY IMAGE TO THE WORKSHEET
ActiveSheet.Paste

End Sub



No comments:

Post a Comment