使用Excel VBA从网页获取链接和URL



以下是错误编号&我得到的描述:

"运行时错误2147417848(80010108(自动化错误调用的对象已从其客户端中断";

调试时突出显示的代码行是:

.Do Until internet.readyState >= 4

代码:

Sub webpage()
Dim internet As Object
Dim internetdata As Object
Dim div_result As Object
Dim header_links As Object
Dim link As Object
Dim URL As String
Set internet = CreateObject("InternetExplorer.Application")
internet.Visible = True
URL = "https://cs.apps.ca.com/otcs/cs.exe? 
func=Projects.ProjectOutline&objid=189982686&ItemType_136="
internet.navigate URL
Do Until internet.readyState >= 4
DoEvents
Loop
Application.Wait Now + TimeSerial(0, 0, 5)
Set internetdata = internet.document
Set div_result = internetdata.getElementById("res")

Set header_links = div_result.getElementsByTagName("h3")
For Each h In header_links
Set link = h.ChildNodes.Item(0)
Cells(Range("A" & Rows.count).End(xlUp).Row + 1, 1) = link.href
Next
MsgBox "done"
End Sub

请在这个上提供帮助

此问题主要与.NET Framework有关。因此,为了解决这个问题,我们需要在运行Windows的PC/笔记本电脑中激活/安装.NET Framework。

参见详细说明:

运行时错误"-2146232576(80131700(":Excel 中的自动化错误

最新更新