Thursday, February 4, 2010

Excel Worksheet to picture using VBA (Jpeg, Png etc)

This sample will show how to automate export of Excel sheet to image file.

You need to download and install ImageMagick library (Q16 version)

When ImageMagick is installed you could use this code to save your Excel worksheet to picture (use "view plain" option to copy code to clipboard):
Dim imObject As Object
'Create ImageMagick Object
Set imObject = CreateObject("ImageMagickObject.MagickImage.1")
'Copy selected area to clipboard as picture
Selection.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
'Save clipboard to image named c:\image.jpg
imObject.Convert "clipboard:myimage", "", "-quality", "85", "c:\image.jpg"

No comments:

Post a Comment