繁体   English   中英

VBA中的Internet Explorer子窗口

[英]Internet Explorer child window in VBA

我有一个VBA代码,可单击IE页面上的链接并打开一个新窗口。 如何获得该子窗口的元素?

我尝试了Shell.application。 还有其他方法吗?

Set objShell = CreateObject("shell.application")
IEcount= objShell.Windows.Count
 For x = 0 To iecount
    On Error Resume Next
    Debug.Print x, objShell.Windows(x).document.Location
 Next x

我得到了窗口号及其URL,但是无法访问页面上的元素。

查看我在您的代码中插入的“ if-then”语句。 您可以使用标题或URL来标识子项并对其进行设置。 一旦获得焦点,就可以获取子窗口的元素。

Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For x = 0 To (IE_count - 1)
    On Error Resume Next    ' sometimes more web pages are counted than are open
    my_url = objShell.Windows(x).Document.Location
    my_title = objShell.Windows(x).Document.Title

    If my_title Like "Something that identifies your child window" Then
        Set ie = objShell.Windows(x)
        Exit For
    Else
    End If
Next

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM