我正在嘗試使用 Excel VBA 導航到網頁、填寫表單并單擊按鈕。現在我正在使用的代碼加載網頁并填寫網頁表單。但是我用來嘗試單擊(“查找”)按鈕的代碼給了我一個運行時錯誤“424”:需要物件。
任何幫助將不勝感激。
這是我正在使用的代碼:
Sub WebForm()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "https://lambda.byu.edu/ae/prod/person/cgi/personLookup.cgi"
IE.Visible = True
While IE.Busy Or IE.readyState <> 4
DoEvents
Wend
IE.document.all("inpSearchPattern").Value = "Some Last Name"
IE.document.all("doNewLookup(document.personxref)").Click
End Sub
uj5u.com熱心網友回復:
試試這個,它對我有用。
Sub WebForm()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "https://lambda.byu.edu/ae/prod/person/cgi/personLookup.cgi"
IE.Visible = True
While IE.Busy Or IE.readyState <> 4
DoEvents
Wend
IE.Document.all("inpSearchPattern").Value = "J*n"
Set objCollection = IE.Document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
'MsgBox "i= " & i & " Name " & objCollection(I).Name & _
" Value " & objCollection(I).Value & _
" Type " & objCollection(I).Type
If (objCollection(i).Value = "Lookup" And objCollection(i).Type = "button") Then
Set objElement = objCollection(i)
End If
i = i 1
Wend
objElement.Click ' click button to load the form
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/329191.html
