Html 如何导航到access VBA中选定标记的href

Html 如何导航到access VBA中选定标记的href,html,ms-access,dom,vba,Html,Ms Access,Dom,Vba,我的程序通过getElementsByTag(“a”)从网站收集标记。在im提取的网站上,每个标记都有一个href链接。通过访问VBA如何进入该href网站 这就是我目前所拥有的 Dim ie As InternetExplorer Dim HTML As HTMLDocument Dim b As IHTMLElement Dim alist As IHTMLElementCollection Set ie = New InternetExplorer ie.Visible = False

我的程序通过
getElementsByTag(“a”)
从网站收集
标记。在im提取的网站上,每个
标记都有一个href链接。通过访问VBA如何进入该href网站

这就是我目前所拥有的

Dim ie As InternetExplorer
Dim HTML As HTMLDocument
Dim b As IHTMLElement
Dim alist As IHTMLElementCollection

Set ie = New InternetExplorer
ie.Visible = False
ie.Navigate ("https://www.example.com")

Set HTML = ie.Document
Set ie = Nothing

Set alist = HTML.getElementsByTagName("a")

For Each b In alist

        Set ie = New InternetExplorer

Next b

只需调用
href
属性即可获得链接:

For Each b In alist

        Set ie = New InternetExplorer
        ie.navigate b.href

        'wait for IE to load
         Do: Loop While ie.busy Or ie.readystate <> 4

Next b
列表中每个b的

Set ie=新的InternetExplorer
ie.b.href
“等我上船
Do:在ie.busy或ie.readystate 4时循环
下一个b

您还需要在初始导航调用中添加“等待IE加载”部分,否则在IE完全加载之前,代码将继续执行。

嘿,在将“等待IE加载调用”添加到初始IE导航后,我的第二个“等待IE调用”(导航到href)将导致错误:“自动化错误,所涉及的对象已与其客户端断开连接“也许不要每次都使用
ie
作为变量名。对第一个网站使用
ie
,然后对每个链接使用
ie1
怎么样。。。或
ie1
<代码>ie2等。。。开始时不要设置
ie=nothing
。嘿,斯科特,回顾一下网站的DOM,我发现href触发了一个javascript函数。我发布了关于这一点的第二个问题: