troubleshooting Question

VBA - 'Object required' error message

Avatar of csehz
csehzFlag for Hungary asked on
SAPVBA
3 Comments1 Solution457 ViewsLast Modified:
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

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
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,
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros