在我认为正确的 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
我收到“调用的对象已与其客户端断开连接的自动化错误”
我从中提取 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>
最佳答案
如果您使用 Set IEexp = New InternetExplorerMedium
您不必更改 Internet 选项中的设置。它使用中等完整性应用程序设置自动实例化 IE 对象。
关于internet-explorer - VBA - IE GetElementByID 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15257179/