Could you please have a look this short code part, briefly its target is assigning a button text (from SAP application) to a variable, but if there is no such button then going further:
ErrMes = session.findById("wnd[2]/usr/txtMESSTXT1").TextDebug.Print ErrMesIf ErrMes Is Nothing Then GoTo NoChangeMessageElse ErrMes = session.findById("wnd[2]/usr/txtMESSTXT1").Text If InStr(1, ErrMes, "change", vbTextCompare) > 0 Then session.findById("wnd[2]/tbar[0]/btn[0]").press End IfEnd If
Actually it has the issue that the ErrMes variable got a value (as Debug.Print shows 'No changes were made' text assigned to it from the button), but then the VBA script stops at line