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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,213,531
Messages
6,114,172
Members
448,554
Latest member
Gleisner2

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