【发布时间】:2021-09-28 02:11:17
【问题描述】:
我在使用网上找到的代码将数据从 Excel 输入到 Web 浏览器时遇到问题,并根据我的需要对其进行了自定义。 他向我报告错误号 424,我不知道如何解决。 在自动数据输入过程中,该站点是否可能出现阻塞? 这是来自网站的代码(检查): 输入 id="input_form1:j_idt26" name="input_form1:j_idt26" type="text" class="form-control searchbox"
Sub SearchBot()
Dim objIE As InternetExplorer 'special object variable representing the IE browser
Dim aEle As HTMLLinkElement 'special object variable for an <a> (link) element
Dim y As Integer 'integer variable we'll use as a counter
Dim result As String 'string variable that will hold our result link
'initiating a new instance of Internet Explorer and asigning it to objIE
Set objIE = New InternetExplorer
'make IE browser visible (False would allow IE to run in the background)
objIE.Visible = True
'navigate IE to this web page (a pretty neat search engine really)
objIE.navigate "https://nbs.rs/sr_RS/drugi-nivo-navigacije/servisi/registar-menica/"
'wait here a few seconds while the browser is busy
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
'in the search box put cell "A2" value, the word "in" and cell "C1" value
objIE.document.getElementById("input_form1:j_idt26").Value = _
Sheets("Sheet1").Range("A2").Value
objIE.document.getElementById("input_form1:j_idt21").Value = _
Sheets("Sheet1").Range("A3").Value
【问题讨论】:
-
错误发生在哪里? objIE.document.getElementById("input_form1:j_idt26") 返回什么?
-
错误出现在:objIE.document.getElementById("input_form1:j_idt26").Value = Sheets("Sheet1").Range("A2").Value 没有回来。跨度>
标签: vba getelementbyid