SAP FB03 download attachment macro

  • Hello guys,
    I created a VBA that downloads from SAP the attachments on transaction Fb03.
    The problem is that when the entry does not have any attachment there's an error. I tried to solve this with the error handler, but it only works for one error, whenever we have a second error, VBA stops. I would appreciate some help with this. Below my code:

  • Try:

    If Err.Number <> 0 Then
    Cells(i, 1).Interior.Color = RGB(255, 0, 0)
    End If

    You can move your On Error line to before the loop.

    Did not work, for the first error works, and highlights the first doc number in red, but the second item without attachment skips the error handler and jumps into the row "session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0" ". When not finding any attachment error appears "Run-time error '-2147024809 (80070057)': "

  • If the error can be controlled, do it like this. The 2nd debug.print will always execute but not the 1st as it causes an error.

  • Solved it, the solution was to do as Kenneth suggested at the beginning, but instead of Err.Clear, On error Goto -1. Big thank you :)

  • Hi.. I coding some thing similar to this but I face issue at below code where in SAP attachment is excel and it wont open until there is manual interventions

    1. session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").currentCellColumn = "BITM_DESCR"
    2. '9. Select the first row in attachment list
    3. session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0"
    4. '10. Double click in the row to open the attachment
    5. session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").doubleClickCurrentCell … Code stops here

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!