Macro from Excel 2013 fails to work in 2016?

fowzan

Board Regular
Joined
Aug 5, 2015
Messages
59
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

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
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,213,567
Messages
6,114,342
Members
448,570
Latest member
rik81h

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top