繁体   English   中英

VBA:IE自动化:从“打开IE窗口”中检索URL; 运行时错误438

[英]VBA: IE Automation: Retrieving URL from Open IE Window; Runtime Error 438

我已经检查了一些有用的线程,有关如何检查Internet Explorer窗口的标题以检索URL。 我有这个:

    Set objShell = CreateObject("Shell.Application")

    For Each wd In objShell.Windows

        If InStr(wd.document.Title, "College") = 1 Then
           Exit For
        End If
    Next wd

    Worksheets("BTS").Cells(2, 2).Value = wd.LocationURL

但是我在If InStr行上不断收到“运行时错误438:对象不支持属性或方法”。 我不知道为什么会引发此错误。 任何帮助,将不胜感激。

一种方法:

Dim objShell, sTitle, wd 

Set objShell = CreateObject("Shell.Application")

For Each wd In objShell.Windows
    sTitle = ""
    On Error Resume Next
    sTitle = wd.document.Title
    On Error Goto 0
    If InStr(sTitle, "College") = 1 Then
       Exit For
    End If
Next wd

Worksheets("BTS").Cells(2, 2).Value = wd.LocationURL

暂无
暂无

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

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