My macro was working for a month or two. We added a printer, so we changed it for the printer. Now it won't save properly, nor will it increase the invoice number properly. As in, when I run it, I will be asked if I want to save the page, when it is supposed to save automatically. Also, the new invoice will save a 1, but the invoice number on the workbook is 2.
Also, a more minor issue, is when I go to use the macro again, all tabs (worksheets) are highlighted. I'm not sure why.
Sub NextInvoice()
' Keyboard Shortcut: Ctrl+q
Worksheets.PrintOut _
From:=1, _
To:=1, _
Copies:=1, _
ActivePrinter:="SHARP MX-M365N PCL6"
Dim NewFN As Variant
' Copy Invoice to new workbook
ActiveSheet.Copy
Range("B14").Value = Range("B14").Value
NewFN = "C:\Users\anviladmin\anvilmachine.ca\Document Portal - Documents\Work Orders\" & Range("P6").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
Range("B14").Formula = "=TODAY()"
ActiveWorkbook.Close
Range("P6").Value = Range("P6").Value + 1
Range("J9, J11, O11:Q11, J12, J15:Q16, J17:Q17, J18:Q28").ClearContents
End Sub
Also, a more minor issue, is when I go to use the macro again, all tabs (worksheets) are highlighted. I'm not sure why.
Sub NextInvoice()
' Keyboard Shortcut: Ctrl+q
Worksheets.PrintOut _
From:=1, _
To:=1, _
Copies:=1, _
ActivePrinter:="SHARP MX-M365N PCL6"
Dim NewFN As Variant
' Copy Invoice to new workbook
ActiveSheet.Copy
Range("B14").Value = Range("B14").Value
NewFN = "C:\Users\anviladmin\anvilmachine.ca\Document Portal - Documents\Work Orders\" & Range("P6").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
Range("B14").Formula = "=TODAY()"
ActiveWorkbook.Close
Range("P6").Value = Range("P6").Value + 1
Range("J9, J11, O11:Q11, J12, J15:Q16, J17:Q17, J18:Q28").ClearContents
End Sub