VBA - IE GetElementByID无法正常工作

And*_*ter 7 internet-explorer vba vbe

我在搜索框中输入文本时遇到了一些麻烦,因为在我认为是严重的ID标签之后.我从页面的源代码中获取了ID.我之前和其他网站一样.有人可以帮帮我吗?还有另一种方法吗?

Sub FileUpload()

Dim IEexp as Object
IEexp.visible = True
IEexp.Navigate ("www.example.com")

'this is where the problem
IEexp.Document.GetElementByID("step1_id_bean_newSupportingDoc_description").Value _ 
= "monthly update"

End Sub
Run Code Online (Sandbox Code Playgroud)

我得到一个"自动化错误调用的对象已与其客户端断开连接"

我从中提取ID的源代码:

<td class="Label">Description</td>
  <td class="Data"><input type="text" name="bean.newSupportingDoc.description" size="60" maxlength="250" value="" id="step1_id_bean_newSupportingDoc_description" class="NoBorder"/>
</td>
Run Code Online (Sandbox Code Playgroud)

use*_*540 0

你可以试试

Do Until IEexp.readyState = 4
DoEvents
Loop



IEexp.Document.getElementById("username").Value = "Monthly update"


IEexp.Document.getElementById("password").Value = FilePth
Run Code Online (Sandbox Code Playgroud)