How check if exists the field? I tried it:
If session.findById("wnd[1]").setFocus Then
To avoid using error handling you can use:
If Not session.findById("wnd[1]", False) Is Nothing Then
session.findById("wnd[1]").setFocus
End If
The key here is the second parameter in FindById which determines if it raises an error or not if the field or any object in SAP exists. If it is set to False there is no error raised and the object is set to Nothing which you can check as in my code.
you can try e.g. the following:
on error resume next
session.findById("wnd[1]").setfocus
if err.number = 0 then
msgbox "The SAP GUI element exists."
else
msgbox "The SAP GUI element does not exist."
end if
on error goto 0
Regards, ScriptMan
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With