I have a document with an invoice number. I want to have a cell value which states the last printed invoice number.
Scenario:
Invoice number is 21. I print the spreadsheet, change the number to 22, save and close.
After this scenario, I want to open the document and read that 21 was the last printed invoice, so that (if I forget to increase the number after printing) I don’t accidentally use the same invoice number (which should be unique).
So, is there a way to add a value to a cell that could read something like “Last printed invoice was 21” after a print command?
I am afraid you cannot attach a function after a print has been invoked. Once you send a document to the print queue, it is not controlled by Excel and the application knows nothing about final results (was it printed? was it cancelled? has it jammed?)
You can add your code to BeforePrint event:
And I believe that should do the trick – you can build a logic, where invoice numbers are unique, although you will not be able to guarantee that all numbers are sequential.
Anyway, for invoicing I would recommend saving/printing/exporting to a PDF file first (with option of overwriting) and printing off the PDF files. It does help for re-prints, e-copies (for an accountant for example) and archiving.