在網上,我看到很多人在完成下面的代碼來自動VBA/IE搜索功能的交互:VBA - 互聯網自動化 - GetElementById.Value缺少
objIE.document.getElementById("id_here").Value = "Search This Text"
- 我收到錯誤「必選對象」運行時,這個。在ObjIE之後,我也失去了智能感知。
我已經研究了幾個小時,現在將非常感謝任何幫助。這是我的完整代碼。我會及時提供解決此問題所需的任何其他信息。
Sub InternetAutomation()
'Declaring and Setting Internet Explorer with Early Binding
Dim aExplorer As InternetExplorer
Set aExplorer = New InternetExplorer
'Set basic attributes of Internet Explorer and navigate to first webpage
With aExplorer
.Visible = True
.Navigate "www.google.com"
End With
'Wait while Internet Explorer is busy
Do While aExplorer.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
'Search Parameters
aExplorer.Document.getElementById("1st - ib").Value = "Search This Text"
End Sub
id值是「lst-ib」,而不是「1st-ib」 –
謝謝!仍然有同樣的問題。有任何想法嗎? – StevenB
適用於我的改變爲編號 –