VBA-IE GetElementByID无法正常工作 [英] VBA - IE GetElementByID not working

查看:159
本文介绍了VBA-IE GetElementByID无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm having some trouble with entering a text in a search box when after I what I think to be the correcet ID tag is. I got the ID from the page's source code. I've done this before with other websites. Can someone please help me out? Is there another way to do this?

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

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

I get a "Automation Error The Object invoked has disconnected from its clients"

我从中提取ID的源代码

Source Code where I pulled the ID from:

<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选项"中的设置.它会使用Medium Integrity Application设置自动实例化IE对象.

If you use Set IEexp = New InternetExplorerMedium you don't have to change the settings in your Internet Options. It automatically instantiates the IE object with Medium Integrity Application settings.

这篇关于VBA-IE GetElementByID无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆