Avatar of csehz
csehz
Flag for Hungary

asked on 

VBA - 'Object required' error message

Dear Experts,

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").Text
Debug.Print ErrMes
If ErrMes Is Nothing Then
    GoTo NoChangeMessage
Else
    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 If
End If

Open in new window


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

If ErrMes Is Nothing Then

Open in new window

with error message:

Run-time error '424'
Object required


Could you please advise what is the nature of the issue there and eventually how to eliminate?

Thanks in advance,
VBASAP

Avatar of undefined
Last Comment
Subodh Tiwari (Neeraj)

8/22/2022 - Mon