The following sub will click a link with the text LinkText in a document, given that you referenced mshtml.tlb and pass a HTMLDocument as the doc parameter (for example WebBrowser.Document):
| Public Sub ClickLink(doc, LinkText As String) For i = 0 To doc.links.length - 1 If LTrim(RTrim(doc.links(i).outerText)) = LinkText Then doc.links(i).Click Exit For End If Next i End Sub |
The following sub will click a link which refers to LinkUrl in a document:
Public Sub ClickLinkUrl(doc, LinkUrl As String)
For i = 0 To doc.links.length - 1
If LTrim(RTrim(doc.links(i).href)) = LinkUrl Then
doc.links(i).Click
Exit For
End If
Next i
End Sub
0 reacties:
Een reactie plaatsen