indesignkat
Member
Hello,
I have a spreadsheet with a list of document numbers. I have vba code that runs a specific transaction code in SAP, pulls up the first document, then prints the invoice attached to that document, then moves on to the next record. I have a snag when the document doesn't have an invoice attached.
Currently the code just moves on to the next record, but I want it to note in the spreadsheet that that invoice didn't print.
What I've tried: after pulling up the document, go into invoice details so you can pull the doc number and put it in the spreadsheet for confirmation. If there's no invoice attached, I get an error. That's cool, On Error to the rescue, but that leads to another problem. I have error handling that says mark the line as 'notprinted' on the spreadsheet, F3 (back up) in SAP so it's ready for the next document number, then loop back around and start over with the next document number. That works great once, but then it appears the error handling is turned off.
I have read that I need "resume"/"resume next" in there after "on error", but if I put that in the code will try to pick up right where it left off after an error. I need it to start over at the beginning with the next document number.
I have tried putting in err.clear in my error handling code, but that doesn't seem to change anything. Nor does On Error GoTo 0.
In short, how do I tell it "ok, forget that error and move on to the next document number"?
I have a spreadsheet with a list of document numbers. I have vba code that runs a specific transaction code in SAP, pulls up the first document, then prints the invoice attached to that document, then moves on to the next record. I have a snag when the document doesn't have an invoice attached.
Currently the code just moves on to the next record, but I want it to note in the spreadsheet that that invoice didn't print.
What I've tried: after pulling up the document, go into invoice details so you can pull the doc number and put it in the spreadsheet for confirmation. If there's no invoice attached, I get an error. That's cool, On Error to the rescue, but that leads to another problem. I have error handling that says mark the line as 'notprinted' on the spreadsheet, F3 (back up) in SAP so it's ready for the next document number, then loop back around and start over with the next document number. That works great once, but then it appears the error handling is turned off.
I have read that I need "resume"/"resume next" in there after "on error", but if I put that in the code will try to pick up right where it left off after an error. I need it to start over at the beginning with the next document number.
I have tried putting in err.clear in my error handling code, but that doesn't seem to change anything. Nor does On Error GoTo 0.
In short, how do I tell it "ok, forget that error and move on to the next document number"?