使用 VBA 将 url 发送到活动的 IE 窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9112048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using VBA to send url to an active IE window
提问by paj
I'm working in VBA and creating Macros in Excel to send info to and from an IE browser window. I've been using AppActivate to focus on the certain IE page using it's title which has worked fine. Using SendKeys to send information back to the browser hasn't 100% gone that well so I've now started using...
我在 VBA 中工作并在 Excel 中创建宏以将信息发送到 IE 浏览器窗口或从 IE 浏览器窗口发送信息。我一直在使用 AppActivate 使用它的标题专注于某个 IE 页面,它运行良好。使用 SendKeys 将信息发送回浏览器并没有 100% 顺利,所以我现在开始使用......
Set ie = New InternetExplorer
ie.Navigate "http://url"
'Loop until ie page is fully loaded
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
ie.Visible = True
followed by code to populate various fields on a web form.
后跟代码以填充 Web 表单上的各个字段。
This all works really well now except that it is currently set to open a new browser window. I've been trying to change the code so it finds the IE window I'm using similarly to AppActivate. But I can't find a way of combining the two. Can anyone help please? How do I change.....
除了当前设置为打开新的浏览器窗口之外,这一切现在都非常有效。我一直在尝试更改代码,以便它找到我使用的类似于 AppActivate 的 IE 窗口。但我找不到将两者结合起来的方法。有人可以帮忙吗?怎么改啊。。。。。。
Set ie = New InternetExplorer
to
到
Set ie = IE WINDOW WITH THIS TITLE.... or something similar?
Many thanks
非常感谢
Paul
保罗
回答by Uri Goren
Please read this link in order to get an IE window by its address
请阅读此链接以通过其地址获取 IE 窗口
http://vba-corner.livejournal.com/4623.html
http://vba-corner.livejournal.com/4623.html
Here is another useful link
这是另一个有用的链接
http://www.excely.com/excel-vba/ie-automation.shtml
http://www.excely.com/excel-vba/ie-automation.shtml
Hope is helps
希望有帮助