How to copy Excel Range as Image using VBA / How to export Excel Range as Image
The following code saves the Excel Range (A1:B2) as an image.
It uses the Export function of the Chart object (Refer :How to Save a Chart as Image using Excel VBA)
to save as Image
Sub Export_Range_Images()
' =========================================
' Code to save selected Excel Range as Image
' =========================================
Dim oRange As Range
Dim oCht As Chart
Dim oImg As Picture
Set oRange = Range("A1:B2")
Set oCht = Charts.Add
oRange.CopyPicture xlScreen, xlPicture
oCht.Paste
oCht.Export FileName:="C:\temp\SavedRange.jpg", Filtername:="JPG"
End Sub
Cool! But how do I set page size and multiple pages from the same spreadsheet and without creating a new spreadsheet with the image?
ReplyDeleteHow can I cope a cell value as the file save name?
ljs2905@gmail.com
Thanks, it helped a lot!
ReplyDeleteHow do you apply this to a button?
ReplyDeleteDoesn't work for me.
ReplyDeleteWindows XP Excel 2003
Err 1004, Method 'Export' of Object '_chart' failed.
wordy1 AT bigpond.com
Call the code from button's click event. It should work
ReplyDelete