Clicking on a link that contains a certain string in VBS

后端 未结 1 2055
不思量自难忘°
不思量自难忘° 2021-01-07 14:23

I\'m trying to run an automated vbs script that clicks on a link on a page. I have things of the form:

Const READYSTATE_COMPLETE = 4  
Set IE = CreateObject(         


        
相关标签:
1条回答
  • 2021-01-07 15:04

    Along the lines of

    Dim LinkHref
    Dim a
    
    LinkHref = "link"
    
    For Each a In IE.Document.GetElementsByTagName("A")
      If LCase(a.GetAttribute("href")) = LCase(LinkHref) Then
        a.Click
        Exit For  ''# to stop after the first hit
      End If
    Next
    

    Instead of LCase(…) = LCase(…) you could also use StrComp(…, …, vbTextCompare) (see StrComp() on the MSDN).

    0 讨论(0)
提交回复
热议问题