从Frame中提取VBA

时间:2016-02-26 17:31:39

标签: html excel vba

我试图提取包含项目列表的页面的详细信息。要获取页面上每个项目的详细信息,我必须单击"详细信息"对于那个项目。然后,这些细节将弹出框架窗口。通过查看框架的源代码,我可以看到我需要的东西。但是,如何让我的VBA代码从父母的页面集合更改为框架集合?请记住,我还需要关闭框架以转到父页面列表中的下一个项目,然后再次打开该项目的框架,依此类推。请帮忙。

这是我到目前为止的代码:

Dim ie As InternetExplorer
Dim Document As HTMLDocument
Dim ele As Object, myURL as String
Dim Document As HTMLDocument
Dim AllLinks As IHTMLElementCollection

Set ie = New InternetExplorer
myURL = Range("Website").Value
ie.navigate (myURL)  ‘URL is set in a named range on the spreadsheet
Do While ie.Busy Or ie.readyState <> 4
    DoEvents
Loop

For Each ele In ie.Document.all
    Set AllLinks = ie.Document.getElementsByTagName("a")
    For Each Hyperlink In AllLinks
    ‘There are several frames, so only open the one where criteria is met            
        If InStr(Hyperlink.href, "Product1234") And InStr(Hyperlink.innerText, "Details") Then
            ‘Opens frame window                
            Hyperlink.Click
            ‘NEED CODE HERE TO INTERACT WITH CHILD FRAME WINDOW THEN GO BACK TO PARENT WINDOW
        End if
    Next Hyperlink
Next ele       

0 个答案:

没有答案