在Internet Explorer中单击一个按钮



我试图使用Excel VBA导航到网页,填写表格,然后单击按钮。现在我正在使用的代码加载网页,并填写网页表单很好。但是我用来尝试点击("查找")按钮的代码给了我一个运行时错误'424':Object Required.

任何帮助都将非常感激。

下面是我使用的代码:
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

试试这个

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

最新更新