Hello community,
I have since the upgrade to Excel 2016 experienced a problem with a macro that generates a jpg image of a designated excel area. In the previous versions, it worked without problems but since the upgrade the macro only generates a blank jpg. Have anyone experienced something similar? The code is the following:
Public Function exportRange(area As Range, ws As Worksheet, path As String)
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Dim output As String
Dim zoom_coef As Single
output = path
zoom_coef = 70 / ws.Parent.Windows(1).Zoom
area.CopyPicture xlPrinter
Dim chartobj As ChartObject: Set chartobj = ws.ChartObjects.Add(0, 0, area.Width * zoom_coef, area.Height * zoom_coef)
chartobj.Select
chartobj.Chart.Paste
chartobj.Chart.Export output, "jpg"
chartobj.Delete
End Function
Bookmarks