Hello,
I included a snippet of a code I use to automate invoice printing one by one, using invoices from Excel.
I have problem to make an error handling code that will handle error #619.
Basically, the way my sub work is that when an invoice is available, it will open a new window "session.findById("wnd[1] " and I can continue to run the code. Otherwise, it will give error # 619. The code I have below only works for the first problematic invoice! 2nd problematic error, it will throw an error.
I tried to handle this by opening a new session when an error occurs, by clearing the error before next loop, but nothing works.
I'd like to request your help to understand what can I do to improve my code.
Thank you
I included a snippet of a code I use to automate invoice printing one by one, using invoices from Excel.
I have problem to make an error handling code that will handle error #619.
Basically, the way my sub work is that when an invoice is available, it will open a new window "session.findById("wnd[1] " and I can continue to run the code. Otherwise, it will give error # 619. The code I have below only works for the first problematic invoice! 2nd problematic error, it will throw an error.
I tried to handle this by opening a new session when an error occurs, by clearing the error before next loop, but nothing works.
I'd like to request your help to understand what can I do to improve my code.
Thank you
Code:
For i = 1 To lstrow
inv = Cells(i, 1).Value
session.sendcommand ("/nVF03")
session.findById("wnd[0]/usr/ctxtVBRK-VBELN").Text = inv
session.findById("wnd[0]/mbar/menu[0]/menu[11]").Select
On Error GoTo here
session.findById("wnd[0]/mbar/menu[0]/menu[11]").Select
session.findById("wnd[1]/usr/tblSAPLVMSGTABCONTROL").getAbsoluteRow(0).Selected = True <--problematic line
session.findById("wnd[1]/tbar[0]/btn[37]").press
session.findById("wnd[0]/tbar[0]/okcd").Text = "pdf!"
session.findById("wnd[0]").sendVKey 0
...
here:
next i