【发布时间】:2019-11-07 11:57:01
【问题描述】:
这是我为获取计算机上所有打开的 Internet Explorer 页面的标题而编写的代码。
Dim objShell As Object
Dim IE_count As Variant
Dim my_url As Variant
Dim my_title As Variant
Dim x As Integer
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
MsgBox ("The number of pages is: " & IE_count)
For x = 0 To (IE_count - 1)
On Error Resume Next
my_url = objShell.Windows(x).Document.Location
my_title = objShell.Windows(x).Document.Title
MsgBox ("The title of this page is: " & my_url)
我的代码中的第一个 MsgBox 实际上显示了正确的 IE_count 数量(代表打开的窗口数量)。
但是,我在显示 my_url 或 my_title 变量时遇到了一些问题。 与这些字段相关的 MsgBox 只是显示“此页面的标题是:”,“是”之后没有任何内容。
您知道如何修复此错误以获取窗口的 url 或标题吗?
PS:我什至尝试将 my_url 和 my_title 的数据类型从变量更改为字符串,但没有任何改变。
非常感谢任何帮助!谢谢你:)
【问题讨论】:
标签: html excel vba internet-explorer