Am stuck and not able to proceed with this. Please find my code below. The code is basically to verify if an element is present in a webpage through VBA. I have created the below sub.
Sub ele_exist(val As String, ele As String)
Select Case val:
Case "byid":
Set verielement = doc.getElementById(ele)
If verielement Is Nothing Then
msgbox("something")
Else
msgbox("something")
End If
Case "byclass":
Set verielement = doc.getElementsByClassName(ele)
If verielement Is Nothing Then
msgbox("something")
Else
msgbox("something")
End If
Case "byname":
Set verielement = doc.getElementsByName(ele)
If verielement Is Nothing Then
msgbox("something")
Else
msgbox("something")
End If
End Select
End Sub
Now when i call this sub it gives syntax error
This is where i call the above sub
Sub start()
Set ie = New InternetExplorer
With ie
.navigate "http://www.google.com"
.Visible = True
While .Busy Or .readyState <> READYSTATE_COMPLETE
DoEvents
Wend
Set doc = .document
DoEvents
End With
***ele_exist ("byname","btnK")*** - THIS IS WHERE SYNTAX ERROR IS DISPLAYED AND THE CODE IS DISPLAYED IN RED
End Sub
I even tried converting it to a boolean FUnction rather than sub, but no luck.
Please help
ele_exist ("byname","btnK")toele_exist "byname","btnK"orCall ele_exist ("byname","btnK"). Also check this post: What is the difference between entering parameters in these four different ways