Abstract

Use this sub if you need to export a worksheet range into a jpg file. I found this is one of the most convenient ways to present Excel results in a PowerPoint presentation. Thanks to my former colleague Ashish P. I could change xlScreen to xlPrinter which will avoid the program to fail in some cases.

Appendix – sbExportRange2Picture Code

Please read my Disclaimer.

Option Explicit

Sub sbExportRange2Picture(sPath As String, rngInput As Range)
'Export range as image
'Source (EN): http://www.sulprobil.de/sbexportrange2picture_en/
'Source (DE): http://www.berndplumhoff.de/sbexportrange2picture_de/
'(C) (P) by Bernd Plumhoff 01-Jun-2016 PB V3.0

Dim chtObj As ChartObject

rngInput.CopyPicture Appearance:=xlPrinter, Format:=xlPicture
Set chtObj = ActiveSheet.ChartObjects.Add(100, 30, 400, 250)
chtObj.Name = "TemporaryPictureChart"
chtObj.Width = rngInput.Width
chtObj.Height = rngInput.Height

'I hate to activate anything. Let me know if you find a better way.
'J.W. suggested chtObj.Chart.ChartArea.Select instead of chtObj.Activate,
'but chtObj might not be active.
chtObj.Activate
ActiveChart.Paste
ActiveChart.Export Filename:=sPath, FilterName:="jpg"

chtObj.Delete

End Sub

Please read my Disclaimer.

sbexportrange2picture.xlsm [22 KB Excel file, open and use at your own risk]