Excel VBA代码获取链接并单击它

时间:2017-05-11 07:07:39

标签: excel-vba vba excel

这是我希望VBA Excel点击的链接的屏幕截图:

link which i want VBA excel to click

导航到所需页面后,我在VBA Excel中使用此代码,但它没有获得我在图片中显示的链接。

    public int compare(Partikel s1, Partikel s2) {
        if(s1.ff > s2.ff) {
            return 1;
        } else if (s1.ff < s2.ff) {
            return -1;
        } else {
            return 0;
        }
    }

1 个答案:

答案 0 :(得分:0)

像这样修改你的代码:

Dim httpObject As Object
Set httpObject = CreateObject("MSXML2.XMLHTTP")
Dim doc As Object
Set doc = CreateObject("htmlfile")
Dim links As Variant

With httpObject
    .Open "GET", "http://www.deltacomputersystems.com/cgi-lra2/LRMCGI01?HTMCNTY=AL39&HTMBASE=C&HTMSEARCH=BEGIN&HTMNAME=ABERCROMBIE+JOE+R&HTMADDRNUMBER=&HTMADDRSTREET=&HTMPARCEL1=&HTMPARCEL2=&HTMPARCEL3=&HTMPARCEL4=&HTMPARCEL5=&HTMPARCEL6=&HTMPARCEL7=&HTMPARCEL8=&HTMPPIN=&HTMSUBMIT=Submit", False
    .send
    Do Until httpObject.ReadyState = 4
    Loop
    doc.body.innerhtml = .responseText
    Set links = doc.getElementsByTagName("a")
    MsgBox (links(0).href)

End With

这是输出

output