[英]run time error 424 object required VBA
我通過嘗試掃描網頁而收到此錯誤
' need to browse the web, I need a browser! So I create an Internet Explorer browser
Dim appIE As Object
Set appIE = CreateObject("internetexplorer.application")
Dim allRowOfDataG As Object
With appIE
.Navigate "https://uk.investing.com/rates-bonds/portugal-government-bonds?maturity_from=70&maturity_to=260"
.Visible = False
End With
Do While appIE.Busy
DoEvents
Loop
'2y
Set allRowOfDataG = appIE.document.getElementById("pair_23784")
及其在Set allRowOfDataG = appIE.document.getElementById(“ pair_23784”)上引發的錯誤
我可以從下面提取一些數據。 也許您應該使appIE
可見以進行故障排除。
Option Explicit
Sub SO41622944()
On Error Resume Next
' need to browse the web, I need a browser! So I create an Internet Explorer browser
Dim appIE As Object
Dim allRowOfDataG As Object, i As Long, sText As String
Set appIE = CreateObject("internetexplorer.application")
If appIE Is Nothing Then Exit Sub
With appIE
.Navigate "https://uk.investing.com/rates-bonds/portugal-government-bonds?maturity_from=70&maturity_to=260"
.Visible = False
Do While .Busy
DoEvents
Loop
'2y
Set allRowOfDataG = .document.getElementById("pair_23784")
If Not allRowOfDataG Is Nothing Then
Debug.Print "Total items in allRowOfDataG: " & allRowOfDataG.all.Length
For i = 0 To allRowOfDataG.all.Length - 1
sText = Trim(allRowOfDataG.all(i).outerText)
If Len(sText) > 0 Then Debug.Print i, sText ' Skip blank cells
Next
Set allRowOfDataG = Nothing
End If
.Quit
End With
Set appIE = Nothing
End Sub
Total items in allRowOfDataG: 14
2 Portugal 2-Year
3 Portugal 2-Year
5 0.258
6 0.261
7 0.311
8 0.226
9 -0.003
10 -1.15%
11 18:00:01
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.