VBA完成Internet表单 [英] VBA to complete a Internet form

查看:380
本文介绍了VBA完成Internet表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Sub FillInternetForm()
Dim IE As Object
设置IE = CreateObject(InternetExplorer.Application)

IE.navigatehttp:// xxxxxxxx /
IE.Visible = True
虽然IE.Busy
DoEvents
Wend
IE.document.getElementById(xxxxx)。Value =xxxx
End Sub

错误出现在IE.document.getElementById(xxxxx)上。Value =xxxx行,它说方法对象IWebBrowser 2失败。



我正在寻找suggstions来解决这个问题:我做了大量的研究,没有任何工作:/



提前感谢:)

解决方案

Ana,
这是一个工作例如,您可以轻松地定制一小段代码为您工作,有一次您必须注意的是,我在工具 - >首选项下添加了对我的项目的引用 - > Microsoft Internet控件。在这一行上,另一个值得注意的一点是在这一行 Set Elements 上,如果你正在寻找不存在的东西,最终会出现错误。我将这个工作示例放在堆栈溢出中,并找到 footer-menu 之下的元素。
如果有些事情没有意义,请让我知道。

  Sub TryInternetExplorer()
'引用到system32 \shdocvw.dll'Microsoft Internet Controls
Dim IEApp As InternetExplorer
设置IEApp =新的InternetExplorer
IEApp.Visible = True
IEApp.Navigatehttps://iam.pearson .com / auth / XUI /#login /
虽然IEApp.ReadyState<> READYSTATE_COMPLETE和IEApp.ReadyState<> READYSTATE_LOADED
DoEvents
Wend

'等待窗体加载
Do
设置form = IEApp.Document.getElementsByTagName(FORM)(0 )'第一个表
DoEvents
循环虽然表单是没有

IEApp.Document.getElementsByName(callback_0)(0).Value =Miguel
IEApp (.document.getElementsByName Document = Nothing
设置IEApp = Nothing


End Sub


I'm looking for a code to put values from an Excel to a Webpage.

Sub FillInternetForm()
  Dim IE As Object
  Set IE = CreateObject("InternetExplorer.Application")

  IE.navigate "http://xxxxxxxx/"
  IE.Visible = True
  While IE.Busy
    DoEvents  
  Wend
  IE.document.getElementById("xxxxx").Value = "xxxx"
End Sub

The error comes in on IE.document.getElementById("xxxxx").Value = "xxxx line and it says Method 'Document' of object 'IWebBrowser 2' failed.

I'm looking for suggstions to solve this question: I made a lot of research and nothing works :/

Thanks in advance :)

解决方案

Ana, Here is a working example. You can easily customized this little bit of code to work for you. One time you must be aware of is that I added a reference to my project under TOOLS -> Preferences -> Microsoft Internet Controls. Also another word of caution is on this line Set Elements on this line, if you are looking for something that does not exists you will end up with an error. This working example I put together goes to stack overflow and finds the elements below footer-menu. Let me know if something does not make sense.

Sub TryInternetExplorer()
 'Reference to system32\shdocvw.dll  'Microsoft Internet Controls
Dim IEApp As InternetExplorer
Set IEApp = New InternetExplorer
IEApp.Visible = True
IEApp.Navigate "https://iam.pearson.com/auth/XUI/#login/"
While IEApp.ReadyState <> READYSTATE_COMPLETE And IEApp.ReadyState <> READYSTATE_LOADED
    DoEvents
Wend

'wait for the form to load
Do
Set form = IEApp.Document.getElementsByTagName("FORM")(0) '1st table
DoEvents
Loop While form Is Nothing

 IEApp.Document.getElementsByName("callback_0")(0).Value = "Miguel"
 IEApp.Document.getElementsByName("callback_1")(0).Value = "pass"
 IEApp.Document.getElementsByName("callback_2")(0).Click


Set Document = Nothing
Set IEApp = Nothing


 End Sub

这篇关于VBA完成Internet表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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