【发布时间】:2021-07-28 23:34:03
【问题描述】:
我正在尝试使用我的脚本。
换句话说:打开了一个带有特定选项卡的 Internet Explorer 窗口,我试图让我的脚本使用其选项卡名称来定位该选项卡。 我查看了这些主题,但没有一个对我有用(或者我做错了):
- Get existing IE via VBA
- Navigate to new URL in existing Internet Explorer window
- VBA Macro For Already Open IE Window
因此我创建了这个(工作了一段时间,直到我无缘无故地收到 438 错误):
Sub FindingExistingIE()
Dim Application As Object
Dim ApplicationWindows As Object
Dim WindowTitle As Variant
Dim TargetWindow As Object
Set Application = CreateObject("Shell.Application")
Set ApplicationWindows = Application.Windows
For Each Application In ApplicationWindows
WindowTitle = Application.Document.Title
If WindowTitle Like "IE Window Title" Then
Set TargetWindow = Application
Exit For
End If
Next Application
NextSub TargetWindow
End
End Sub
正如我所说,脚本可以正常运行一周,但现在我收到 438 错误:
对象不支持此属性或方法(错误 438)
错误突出显示以下行:
WindowTitle = Application.Document.Title
阅读Microsoft Doc related to the error 后,我尝试将WindowTitle 变量更改为一个对象。没用。
有人有想法吗?
谢谢!
【问题讨论】:
-
我在这里的回答对我来说一直很好 - stackoverflow.com/questions/31167200/… Shell
Windows集合还包括 Windows 资源管理器窗口,它没有Document属性,所以你必须处理这种情况. -
我用
.Name替换了.Document.Title,现在我有一个不同的错误! 91 错误...
标签: vba object internet-explorer