Hello,
I have a code that works perfectly every time when I step through it, however when I play it normally it does not. It will save a white image rather than the range.
This code saves a range as a .PNG. It took me forever to find one that worked the way I want it to. What I like about this method is it works zooming in and saving the file as a large image as I am displaying them on large TV displays.
I think it is the chart.paste piece that messes up. If a play up to that then step it works, if I play just past it then step it does not work.
I have tried different methods of this that have not worked in the way I like.
I have a code that works perfectly every time when I step through it, however when I play it normally it does not. It will save a white image rather than the range.
This code saves a range as a .PNG. It took me forever to find one that worked the way I want it to. What I like about this method is it works zooming in and saving the file as a large image as I am displaying them on large TV displays.
I think it is the chart.paste piece that messes up. If a play up to that then step it works, if I play just past it then step it does not work.
I have tried different methods of this that have not worked in the way I like.
Code:
Sub test2()
Set Sheet = Worksheets("test_sheet")
Sheets("test_sheet").Select
output = "C:\Users\matthew.harnden\Documents\test_image.png"
zoom_coef = 100 / Sheet.Parent.Windows(1).Zoom * 4
Set area = Worksheets("test_sheet").Range("B7:O30")
area.CopyPicture xlBitmap
Set chartobj = Sheet.ChartObjects.Add(0, 0, area.Width * zoom_coef, area.Height * zoom_coef)
chartobj.Chart.Paste
chartobj.Chart.Export output, "png"
chartobj.Delete
End Sub