Hi,
I have been using a macro to save an image on my company's invoice. I have been using this from past 4 months without any issues. But recently we upgraded from Office 2013 to office 2016 and now the macro fails to work properly.
I have no idea why. Can someone please help me fix the issue
I have been using a macro to save an image on my company's invoice. I have been using this from past 4 months without any issues. But recently we upgraded from Office 2013 to office 2016 and now the macro fails to work properly.
I have no idea why. Can someone please help me fix the issue
Code:
Sub saveimage()
Set Sheet = ActiveSheet
output = "F:\Invoices\" & Range("e8") & ".png"
zoom_coef = 100 / Sheet.Parent.Windows(1).Zoom
Dim sht As Worksheet
Dim LastRow As Long
Dim LastColumn As Long
Dim StartCell As Range
Set sht = Worksheets("Invoice")
Set StartCell = Range("A1")
'Refresh UsedRange
Worksheets("Invoice").UsedRange
'Find Last Row
LastRow = sht.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
'Select Range
sht.Range("A1:N" & LastRow).Select
Set area = Selection
area.CopyPicture xlPrinter
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